Env provides a similar interface for environment variables as flag/pflag package.
The interface follows closely the flag/pflag packages.
package main
import "github.com/goph/env"
func main() {
// Define environment variables using env.String(), Bool(), Int(), etc.
var intValue *int = env.Int("int", 1234, "help message for int")
// If you like, you can bind the environment variable to a variable using the Var() functions.
var intVar int
env.IntVar(&intVar, "int", 1234, "help message for int")
// Or you can create custom variables that satisfy the Value interface (with pointer receivers)
// and couple them to variable parsing.
//
// For such environment variables, the default value is just the initial value of the variable.
var intVal env.Value
env.Var(&intVal, "int", "help message for int")
// After all variables are defined.
env.Parse()
}
When all coding and testing is done, please run the test suite:
$ make test # go test
For linting we use GolangCI.
$ make lint # golangci-lint run
You can run the whole suite with:
$ make check
The MIT License (MIT). Please see License File for more information.