Categorygithub.com/jhunt/go-envirotron
repositorypackage
0.0.0-20191007155228-c8f2a184ad0f
Repository: https://github.com/jhunt/go-envirotron.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Envirotron

Travis CI

Ever wanted to easily allow users to override configuration values in a Go program via environment variables, but didn't want to deal with the tedium of checking that variables are set, and the harrowing existential crisis of determing what is true?

Want no more!

package thing

import (
  "fmt"
  env "github.com/jhunt/go-envirotron"
)

type Config struct {
  URL      string `env:"THING_URL"`
  Username string `env:"THING_USERNAME"`
  Password string `env:"THING_PASSWORD"`
}

func main() {
  c := Config{}
  env.Override(&c)

  fmt.Printf("connecting to %s, as %s\n", c.URL, c.Username)
}

Happy Hacking!