fileloader

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedFileFormat = errors.New("unsupported file format")

Functions

func Decoders

func Decoders() map[string]Decoder

func New

func New(opts ...Option) func() loader.Loader

Types

type Decoder

type Decoder = func(r io.Reader, to any) error

type Loader

type Loader struct {
	FileSuffix []string
	Folders    []string
	Decoders   map[string]Decoder
	MapDecoder func(data any, to any) error
}

func (Loader) LoadChu

func (l Loader) LoadChu(ctx context.Context, to any, opt *loader.Option) error

Load loads the configuration from the file.

  • first it checks the current directory after that it checks the etc folder.
  • CONFIG_PATH environment variable is used to determine the file path.

type Option added in v0.2.0

type Option func(*option)

func WithDecoders added in v0.2.0

func WithDecoders(decoders map[string]Decoder) Option

WithDecoders sets the decoders to use when loading the configuration.

  • order matters

func WithFileSuffix added in v0.2.0

func WithFileSuffix(suffixes ...string) Option

WithFileSuffix sets the file suffixes to use when loading the configuration.

  • order matters

func WithFolders added in v0.2.0

func WithFolders(folders ...string) Option

WithFolders sets the folders to use when loading the configuration.

  • order matters

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL