Documentation ¶
Overview ¶
Package env provides a convenient way to convert environment variables into Go data. It is similar in design to package flag.
Index ¶
- func Bool(name string, value bool) *bool
- func BoolVar(p *bool, name string, value bool)
- func Duration(name string, value time.Duration) *time.Duration
- func DurationVar(p *time.Duration, name string, value time.Duration)
- func Int(name string, value int) *int
- func IntVar(p *int, name string, value int)
- func Parse()
- func String(name string, value string) *string
- func StringSlice(name string, value ...string) *[]string
- func StringSliceVar(p *[]string, name string, value ...string)
- func StringVar(p *string, name string, value string)
- func URL(name string, value string) *url.URL
- func URLVar(p *url.URL, name string, value string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool returns a new bool pointer. When Parse is called, env var name will be parsed and the resulting value will be assigned to the returned location. Parsing uses strconv.ParseBool.
func BoolVar ¶
BoolVar defines a bool var with the specified name and default value. The argument p points to a bool variable in which to store the value of the environment variable.
func Duration ¶
Duration returns a new time.Duration pointer. When Parse is called, env var name will be parsed and the resulting value will be assigned to the returned location.
func DurationVar ¶
DurationVar defines a time.Duration var with the specified name and default value. The argument p points to a time.Duration variable in which to store the value of the environment variable.
func Int ¶
Int returns a new int pointer. When Parse is called, env var name will be parsed and the resulting value will be assigned to the returned location.
func IntVar ¶
IntVar defines an int var with the specified name and default value. The argument p points to an int variable in which to store the value of the environment var.
func Parse ¶
func Parse()
Parse parses known env vars and assigns the values to the variables that were previously registered. If any values cannot be parsed, Parse prints an error message for each one and exits the process with status 1.
func String ¶
String returns a new string pointer. When Parse is called, env var name will be assigned to the returned location.
func StringSlice ¶
StringSlice returns a pointer to a slice of strings. It expects env var name to be a list of items delimited by commas. If env var name is missing, StringSlice returns a pointer to a slice of the value strings.
func StringSliceVar ¶
StringSliceVar defines a new string slice with the specified name. The argument p points to a string slice variable in which to store the value of the environment var.
func StringVar ¶
StringVar defines a string with the specified name and default value. The argument p points to a string variable in which to store the value of the environment var.
Types ¶
This section is empty.