package main import ( "fmt" "time" "github.com/caarlos0/env" ) type config struct { Home string `env:"HOME"` Port int `env:"PORT" envDefault:"3000"` IsProduction bool `env:"PRODUCTION"` Hosts []string `env:"HOSTS" envSeparator:":"` Duration time.Duration `env:"DURATION"` } func main() { cfg := config{} err := env.Parse(&cfg) if err != nil { fmt.Printf("%+v\n", err) } fmt.Printf("%+v\n", cfg) }