Documentation
¶
Index ¶
- func Load(cfg any, opts ...Option) error
- func LoadForTests(cfg any, opts ...Option) error
- type Option
- func WithAllowUnknownFields(v bool) Option
- func WithContext(v context.Context) Option
- func WithEnvFile(v string) Option
- func WithSkipFlags(v bool) Option
- func WithValidate(v bool) Option
- func WithValidateFuncs(items ...ValidateFn) Option
- func WithVersion(v string) Option
- func WithYamlFile(v string) Option
- type ValidateFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
Load environment variables from `os env`, flags, `.env`, `.yaml` files and pass it to struct.
For local development use `.env` file from root project.
Load also call a `Validate` method if it proided.
Example:
var config internalConfig.Config
if err := cfg.Load(&config); err != nil {
logger.Fatalf("could not load configuration: %v", err)
}
func LoadForTests ¶ added in v0.0.10
LoadForTests environment variables from `os env`, flags, `.env`, `.yaml` files and pass it to struct.
Disabled flags detection and any cli features.
For local development use `.env` file from root project.
LoadForTests also call a `Validate` method if it proided.
Example:
var config internalConfig.Config
if err := cfg.LoadForTests(&config); err != nil {
logger.Fatalf("could not load configuration: %v", err)
}
Types ¶
type Option ¶
type Option func(*options)
func WithAllowUnknownFields ¶ added in v0.2.14
WithAllowUnknownFields - allow unknown fields in config
By default it true
func WithContext ¶
func WithValidate ¶
func WithValidateFuncs ¶
func WithValidateFuncs(items ...ValidateFn) Option
func WithVersion ¶
func WithYamlFile ¶ added in v0.2.14
WithYamlFile path to yaml config file
Click to show internal directories.
Click to hide internal directories.