package
0.0.0-20231126024412-02539191b02e
Repository: https://github.com/mjpitz/myago.git
Documentation: pkg.go.dev
# README
config
import go.pitz.tech/lib/config
Usage
var (
// ErrFileDoesNotExist is returned when the file we're interacting with does not exist.
ErrFileDoesNotExist = errors.New("file does not exist")
// ErrFileMissingExtension is returned when the provided file is missing an extension.
ErrFileMissingExtension = errors.New("file missing extension")
// ErrUnsupportedFileExtension is returned when we don't recognize a given file extension.
ErrUnsupportedFileExtension = errors.New("unsupported file extension")
)
var DefaultLoader = Loader{
".json": encoding.JSON,
".toml": encoding.TOML,
".yaml": encoding.YAML,
".yml": encoding.YAML,
".xml": encoding.XML,
}
DefaultLoader provides a default Loader implementation that supports reading a variety of files.
func Load
func Load(ctx context.Context, v interface{}, filePaths ...string) error
Load provides a convenience function for being able to load configuration using the DefaultLoader.
type Loader
type Loader map[string]*encoding.Encoding
Loader provides functionality for reading a variety of file formats into a struct.
func (Loader) Load
func (l Loader) Load(ctx context.Context, v interface{}, filePaths ...string) error
Load reads the provided files (if they exist) and unmarshals the data into the provided interface.
# Functions
Load provides a convenience function for being able to load configuration using the DefaultLoader.
# Variables
DefaultLoader provides a default Loader implementation that supports reading a variety of files.
ErrFileDoesNotExist is returned when the file we're interacting with does not exist.
ErrFileMissingExtension is returned when the provided file is missing an extension.
ErrUnsupportedFileExtension is returned when we don't recognize a given file extension.
# Type aliases
Loader provides functionality for reading a variety of file formats into a struct.