Skip to content

Go environment utilities (genvutils) - provides useful environment variables operations

License

Notifications You must be signed in to change notification settings

lalabuy948/genvutils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

genvutils Go Report Card Build Status

Package genvutils provides useful environment operations

Funcs

  • IsProduction, IsDevelopment and IsTesting checks for ENVIRONMENT dot env value.
  • GetEnv gets env value or fallback which goes as second function argument.
  • Parse will fill given struct with env values or with fallbacks. (see examples folder)
	type serverConfig struct {
		ServerPort string `genv:"SERVER_PORT,8080"`
		MongoUrl   string `genv:"MONGO_URL,mongodb://localhost:27017"`
	}
  • Load will load dotenv file. You can provide file name via argument otherwise it will load dot environment file by priority list. First found - first load. Priority list:
.env.production.local
.env.test.local
.env.development.local
.env.production
.env.test
.env.development
.env.local !!! will override existing values.
.env

example

Install

go get -u github.com/lalabuy948/genvutils