Documentation ¶
Overview ¶
Package genvutils provides useful environment operations
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDotenvNotFound = errors.New("genvutils: no dot environment files found")
Functions ¶
func GetEnv ¶
GetEnv extracts env value by provided key, otherwise falls back to second function argument.
func IsDevelopment ¶
func IsDevelopment() bool
IsDevelopment checks if ENVIRONMENT value is equal to "DEV" or "DEVELOPMENT".
func IsProduction ¶
func IsProduction() bool
IsProduction checks if ENVIRONMENT value is equal to "PROD" or "PRODUCTION".
func IsStaging ¶
func IsStaging() bool
IsStaging checks if ENVIRONMENT value is equal to "STAGE" or "STAGING".
func IsTesting ¶
func IsTesting() bool
IsTesting checks if ENVIRONMENT value is equal to "TEST" or "TESTING".
func Load ¶
Load function is going to parse given dot environment file or chose one from priority list and set environment variables.
!!! It will not override already set variables. Except .env.local
Priority list is next (top -> bottom): .env.production.local .env.test.local .env.development.local .env.production .env.test .env.development .env.local !!! will override existing values. .env
func Parse ¶
func Parse(income interface{}) error
Parse function will parse given pointer to struct and fill it with env values.
type serverConfig struct { ServerPort string `genv:"SERVER_PORT,8080"` MongoUrl string `genv:"MONGO_URL,mongodb://localhost:27017"` }
Here is an example of struct. Good reading about reflect https://github.com/a8m/reflect-examples
Types ¶
This section is empty.