loaderfile

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 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) 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
	CheckCurrentFolder bool
	CheckEnv           bool
	MapDecoder         func(data any, to any) error
}

func (Loader) Load added in v0.4.0

func (l Loader) Load(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.

func (*Loader) LoadName added in v0.4.0

func (l *Loader) LoadName() loader.LoaderName

func (*Loader) LoadOrder added in v0.4.0

func (l *Loader) LoadOrder() loader.Order

type Option

type Option func(*option)

func WithCheckCurrentFolder added in v0.4.0

func WithCheckCurrentFolder(v bool) Option

WithCheckCurrentFolder enables loading configuration from the current folder.

  • default is true

func WithCheckEnv added in v0.4.0

func WithCheckEnv(v bool) Option

WithCheckEnv enables loading configuration from the path specified in CONFIG_PATH environment variable.

  • default is true

func WithDecoders

func WithDecoders(decoders map[string]Decoder) Option

WithDecoders sets the decoders to use when loading the configuration.

  • order matters

func WithFileSuffix

func WithFileSuffix(suffixes ...string) Option

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

  • order matters

func WithFolders

func WithFolders(folders ...string) Option

WithFolders sets the folders to use when loading the configuration.

  • order matters
  • default is /etc

Jump to

Keyboard shortcuts

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