Skip to content
/ goenv Public

Populate go struct instance with OS environment variables.

License

Notifications You must be signed in to change notification settings

ggicci/goenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goenv

Populate go struct instance with OS environment variables.

Go codecov Go Report Card Go Reference

LIMITATION: only string fields can be tagged with env tag.

type MyAppConfig struct {
	Workspace string `env:"name=MYAPP_HOME"`
	User      string `env:"name=MYAPP_USER"`
	Debug     string `env:"name=MYAPP_DEBUG"`
}

var config = new(MyAppConfig)
if err := goenv.Load(config); err != nil { ... }

if config.Debug == "1" {
    // enable debug output
}

About

Populate go struct instance with OS environment variables.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages