$ go get -u clevergo.tech/osenvGets the environment variable associated with the given key, a fallback(default) value will be returned if not exist.
Assume environment is that FOO=BAR EMPTY=.
| Method | Value |
|---|---|
osenv.Get("FOO") |
BAR |
osenv.Get("EMPTY") |
- |
osenv.Get("EMPTY", "BUZZ") |
- |
osenv.Get("FIZZ") |
- |
osenv.Get("FIZZ", "BUZZ") |
BUZZ |
Similar functions:
GetInt
Gets the environment variable associated with the given key, and panics if not exist.
osenv.MustGet("FOO") // BAR
osenv.MustGet("NIL") // panicsSimilar functions:
MustGetInt
Sets an environment variable if not exist.
osenv.SetNX("NONEXISTENT", "VALUE")