Documentation ¶
Overview ¶
The param package is a management system for configuration parameters. Much like the standard library "flags" package, the param package allows parameters to be defined in the file they are needed without requiring direct linkage between the usage location and the configuration parser.
In typical use, each parameter is defined as a package-level variable. During initialization, the program provides a map[string]string containing parameter configuration data. This map is expected to be parsed from a configuration file.
Because the tasks are so similar, this package is implemented by re-using the low-level types from the standard "flag" module.
Example parameter declaration:
var threshold = param.Int("threshold", 5)
Parameter use:
if numUsed >= *threshold { ... }
Parsing from a config file:
var config struct { FormalValue string Params param.Values } yaml.Unmarshal(readConfigFile(), &config) err := param.Parse(config.Params)
Index ¶
- Variables
- func Bool(name string, value bool) *bool
- func Float64(name string, value float64) *float64
- func Int(name string, value int) *int
- func Int64(name string, value int64) *int64
- func Parse(values Values) error
- func ParseFlags(f *flag.FlagSet, values Values) error
- func String(name string, value string) *string
- type Values
Constants ¶
This section is empty.
Variables ¶
var DefaultParams flag.FlagSet
DefaultParams holds the default set of parameters, used by all package-level functions.
Functions ¶
func Parse ¶
Parse parses the parameter assignments for the default set of parameters. See ParseFlags().
func ParseFlags ¶
ParseFlags parses a map of parameter assignments that are defined by a FlagSet.