Manage your application config as a typesafe struct in as little as two function calls.
How It Works
Its just simple, pure stdlib.
- A field’s type determines what strconv function is called.
- All string conversion rules are as defined in the strconv package
- If chaining multiple data sources, data sets are merged. Later values override previous values. config.From(“dev.config”).FromEnv().To(&c)
- Unset values remain as their native zero value
Nested structs/subconfigs are delimited with double underscore
Env vars map to struct fields case insensitively
- NOTE: Also true when using struct tags.
Why you should use this
- Its the cloud-native way to manage config. See 12 Factor Apps
- only 2 lines to configure.
- Merge local files and environment variables for effortless local development.
- only stdlib
- < 180 LoC