Help us shape the future of Go! Take the 2026 Go Developer Survey

getenv

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

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

Go to latest
Published: Dec 7, 2019 License: MIT Imports: 3 Imported by: 0

README

I needed a cleaner way to get environment variables with default values.

var (
        somevar = getenv.Getenv("TOOL_SOMEVAR", "default_value")
)

One might also have to process many variables with the same prefix

env := getenv.NewEnv("TOOL")
var somevar = env.Getenv("SOMEVAR", "default_value")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Getenv

func Getenv(varname, defvalue string) string

func GetenvBool

func GetenvBool(varname string, defvalue bool) bool

func GetenvInt

func GetenvInt(varname string, defvalue int) int

Types

type Env

type Env struct {
	// contains filtered or unexported fields
}

func NewEnv

func NewEnv(prefix string) *Env

func (*Env) Get

func (e *Env) Get(suffix, defvalue string) string

func (*Env) GetBool

func (e *Env) GetBool(suffix string, defvalue bool) bool

func (*Env) GetInt

func (e *Env) GetInt(suffix string, defvalue int) int

Jump to

Keyboard shortcuts

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