envirotron

package module
v0.0.0-...-c8f2a18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2019 License: MIT Imports: 4 Imported by: 27

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!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Override

func Override(thing interface{})

Types

type Unmarshaler

type Unmarshaler interface {
	UnmarshalEnv(string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL