Go environment utils
- Simple API.
- Dependency-free.
- Clean and tested code.
- Fully compatible with
env
package.
See GUIDE.md for more details.
Go version 1.17+
go get github.com/cristalhq/envx
envs := []string{"ENVX_TIMEOUT=20s"} // or os.Environ()
var d time.Duration
eset := envx.NewEnvSet("ENVX")
eset.Duration(&d, "TIMEOUT", 10*time.Second, "just a timeout")
err := eset.Parse(envs)
if err != nil {
panic(err)
}
fmt.Println(d)
// Output: 20s
Also see examples: examples_test.go.
See these docs.