Documentation
¶
Overview ¶
Package config implements a minimal viable config library.
Only configuration through environment variables are supported.
Example (Basic) ¶
os.Setenv("NUM", "69")
var n int
fmt.Printf("%d\n", n)
config.Int(&n, "num")
fmt.Printf("%d\n", n)
Output: 0 69
Index ¶
- func Enum(value flag.Value, key string, values ...string) error
- func Float64(p *float64, key string) error
- func Int(p *int, key string) error
- func Int64(p *int64, key string) error
- func SetPrefix(s string)
- func String(p *string, key string) error
- func Text(p encoding.TextUnmarshaler, key string) error
- func Uint(p *uint, key string) error
- func Uint64(p *uint64, key string) error
- func Value(value flag.Value, key string) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Enum ¶
Enum sets a flag.Value from an environment variable, from a limited set of allowed values.
func SetPrefix ¶
func SetPrefix(s string)
SetPrefix adds a prefix to all keys used to set values.
Example ¶
os.Setenv("FOO_NUM", "69")
config.SetPrefix("foo_")
var n int
fmt.Printf("%d\n", n)
config.Int(&n, "num")
fmt.Printf("%d\n", n)
Output: 0 69
func Text ¶
func Text(p encoding.TextUnmarshaler, key string) error
Text sets an encoding.TextUnmarshaler value from an environment variable.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.