chore: load config from env file
This commit is contained in:
parent
5213612033
commit
aa9ed05903
5 changed files with 79 additions and 2 deletions
25
cmd/config/config.go
Normal file
25
cmd/config/config.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package config
|
||||
|
||||
import "github.com/kelseyhightower/envconfig"
|
||||
|
||||
type (
|
||||
// Config provides the system configuration.
|
||||
Config struct {
|
||||
Logging Logging
|
||||
}
|
||||
)
|
||||
|
||||
type Logging struct {
|
||||
Debug bool `envconfig:"APP_LOGS_DEBUG"`
|
||||
Level string `envconfig:"APP_LOGS_LEVEL" default:"info"`
|
||||
NoColor bool `envconfig:"APP_LOGS_COLOR"`
|
||||
Pretty bool `envconfig:"APP_LOGS_PRETTY"`
|
||||
Text bool `envconfig:"APP_LOGS_TEXT"`
|
||||
}
|
||||
|
||||
// Environ returns the settings from the environment.
|
||||
func Environ() (Config, error) {
|
||||
cfg := Config{}
|
||||
err := envconfig.Process("", &cfg)
|
||||
return cfg, err
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue