Package env provides tools for working with environment-variables, for the Go programming language.
- Go 100%
| internal | initial commits | |
| get.go | refactor | |
| get_nothing_test.go | tests | |
| get_something_test.go | tests | |
| getelse.go | docs | |
| getoptional.go | fix | |
| getoptional_nothing_test.go | tests | |
| getoptional_something_test.go | tests | |
| go.mod | go.* | |
| go.sum | go.* | |
| LICENSE | initial commits | |
| mustget.go | erorr | |
| README.md | initial commits | |
| type.go | refactor | |
| vars.go | initial commits | |
go-env
Package env provides tools for working with environment-variables, for the Go programming language.
Documention
Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-env
Examples
Here is an example of getting the value of the environment-variable PORT as a uint16:
tcpport,found:=env.Get[uint16]("PORT")Here is an example of getting the value of the environment-variable PORT as a uint16,
and it doesn't exist or isn't a uint16 number, then defaulting it to 8080:
tcpport:=env.GetElse[uint16]("PORT",8080)Here is an example of getting the value of the environment-variable SHELL as a string:
shell,found:=env.Get[string]("SHELL")Import
To import package env use import code like the following:
import "github.com/reiver/go-env"
Installation
To install package env do the following:
GOPROXY=direct go get github.com/reiver/go-env
Author
Package env was written by Charles Iliya Krempeaux