Popularity
0.5
Growing
Activity
0.0
-
1
2
0

Description

Implements a simple way of handling environment values. Each environment field is simply reflected by a variable inside the Go program. Out of the box handlers for the types bool, []byte, time.Duration, int, string and []string are provided. Other types can be added by using the RegisterField function.

Programming language: Go
Tags: Configuration     Go     Golang     Environment    

go-env alternatives and similar packages

Based on the "Configuration" category

Do you think we are missing an alternative of go-env or a related project?

Add another 'Configuration' Package

README

env

GoDoc Build Status

Implements a simple way of handling environment values. Each environment field is simply reflected by a variable inside the Go program. Out of the box handlers for the types bool, []byte, time.Duration, int, []int, string and []string are provided. Other types can be added by using the RegisterField function.

Example

var (
    name = env.String("NAME", "joe")
    age  = env.Int("AGE", 24)
)

func main() {
    env.ParseFlags()

    fmt.Printf("%s is %d years old\n", name.Get(), age.Get())
}

If the program is called with -print short-bash, all registered environment fields would be printed...

NAME="joe"
AGE="24"

By using -print long-bash, a description for each field is generated.

# String field. The default value is 'joe'.
NAME="joe"

# Int field. The default value is '24'.
AGE="24"

License

The project is licensed under Apache 2.0.


*Note that all licence references and agreements mentioned in the go-env README section above are relevant to that project's source code only.