Skip to content
/ env Public

Convenient work with environment variables in Golang

License

Notifications You must be signed in to change notification settings

plin2k/env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Convenient work with environment variables

Example Usage

Global

env.SetDefault("fooString", "bar")
env.SetDefault("fooInt", 825)
env.SetDefault("fooInt64", 125)
env.SetDefault("fooFloat64", 11.22)
env.SetDefault("fooBool", true)

if env.IsSet("fooNotExists") {
	return errors.New("environment variable not exists")
}

env.GetString("fooString")
env.GetInt("fooInt")
env.GetInt64("fooInt64")
env.GetFloat64("fooFloat64")
env.GetBool("fooBool")

Custom

myEnv := env.New()

myEnv.SetDefault("fooString", "bar")
myEnv.SetDefault("fooInt", 825)
myEnv.SetDefault("fooInt64", 125)
myEnv.SetDefault("fooFloat64", 11.22)
myEnv.SetDefault("fooBool", true)

if myEnv.IsSet("fooNotExists") {
	return errors.New("environment variable not exists")
}

myEnv.GetString("fooString")
myEnv.GetInt("fooInt")
myEnv.GetInt64("fooInt64")
myEnv.GetFloat64("fooFloat64")
myEnv.GetBool("fooBool")

About

Convenient work with environment variables in Golang

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages