Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fill ¶
func Fill(vars interface{}) error
Fill uses environment variables or defaults to assign values to element of a struct.
Example ¶
package main import ( "fmt" "os" "github.com/fabritsius/envar" ) func main() { // create couple environment variables createCoupleEnvs() type config struct { Name string `env:"HERO"` Place string `env:"PLACE"` } cfg := config{} if err := envar.Fill(&cfg); err != nil { panic(err) } fmt.Printf("You gotta do it for Grandpa, %s. You gotta put these seeds inside your %s.\n", cfg.Name, cfg.Place) } func createCoupleEnvs() { os.Setenv("HERO", "Bob") os.Setenv("PLACE", "backpack") }
Output: You gotta do it for Grandpa, Bob. You gotta put these seeds inside your backpack.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.