Skip to content

cristalhq/envx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

envx

build-img pkg-img reportcard-img coverage-img version-img

Go environment utils

Features

  • Simple API.
  • Dependency-free.
  • Clean and tested code.
  • Fully compatible with env package.

See GUIDE.md for more details.

Install

Go version 1.17+

go get github.com/cristalhq/envx

Example

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.

Documentation

See these docs.

License

MIT License.