env

package
v0.0.0-...-58998d9 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package env provides utility functions for loading environment variables with defaults.

A common use of the env package is for combining flag with environment variables in a Go program.

Example:

func main() {
	var (
		flProject = flag.String("http.addr", env.String("HTTP_ADDRESS", ":https"), "HTTP server address")
	)
	flag.Parse()
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(key string, def bool) bool

Bool returns the environment variable value specified by the key parameter, otherwise returning a default value if set.

func Duration

func Duration(key string, def time.Duration) time.Duration

Duration returns the environment variable value specified by the key parameter, otherwise returning a default value if set. If the time.Duration value cannot be parsed, Duration will exit the program with an error status.

func String

func String(key, def string) string

String returns the environment variable value specified by the key parameter, otherwise returning a default value if set.

Types

This section is empty.

Jump to

Keyboard shortcuts

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