Skip to content

clevergo/osenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Extensional OS environment variables helper for Go.

Build Status Coverage Status Go.Dev reference Go Report Card Release Downloads Chat Community

Usage

$ go get -u clevergo.tech/osenv

Get

Gets 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

MustGet

Gets the environment variable associated with the given key, and panics if not exist.

osenv.MustGet("FOO") // BAR
osenv.MustGet("NIL") // panics

Similar functions:

  • MustGetInt

SetNX

Sets an environment variable if not exist.

osenv.SetNX("NONEXISTENT", "VALUE")

About

An extensional OS environment variables helper for Go

Topics

Resources

License

Stars

Watchers

Forks

Languages