github.com/42z-io/confik@v0.0.2-0.20231103050132-21d8f377356c/config.go (about) 1 package confik 2 3 import "reflect" 4 5 // Config[T] is the configuration for reading environment variables. 6 type Config[T any] struct { 7 UseEnvFile bool // read from an environment file on disk? 8 EnvFilePath string // custom path to the environment file (otherwise search for ".env") 9 EnvFileOverride bool // should variables found in the env file override environment variables? 10 Validators map[string]Validator // a map of custom validators to be used by the loader 11 Parsers map[reflect.Type]Parser // a map of custom type parsers to be used by the loader 12 DefaultValue *T // default values to use if they do not exist in the environment 13 } 14 15 // DefaultConfig will create a new [Config] with the default values. 16 func DefaultConfig[T any]() Config[T] { 17 return Config[T]{ 18 UseEnvFile: true, 19 EnvFilePath: "", 20 EnvFileOverride: false, 21 DefaultValue: nil, 22 } 23 }