Documentation
¶
Overview ¶
Package env provides helper functions to load environment variables with some degree of control of behavior like: empty, prefixes, default and mutators. All these beneficits come from github.com/sethvargo/go-envconfig.
Basics:
Define your configuration struct:
type MyConfig struct{ User string `env:"USER,default=facily"` Password string `env:"PASSWORD,required"` Timeout time.Duration `env:"TIMEOUT,default=10s"` }
Somewhere create a instance of MyConfig and call LoadEnv:
var config MyConfig if err := LoadEnv(ctx, &config, "PREFIX_"); err != nil { ... }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadEnv ¶
func LoadEnv(ctx context.Context, dst interface{}, prefix string, mutators ...MutatorFunc) error
LoadEnv bring a set of environment variables defined in dst with prefix. Mutators provide a way to change environment variables before defining dst value. We wrap github.com/sethvargo/go-envconfig functionality.
Types ¶
Click to show internal directories.
Click to hide internal directories.