Documentation
¶
Overview ¶
Package env parses environments using the fields from a struct.
For example,
var envs struct {
Iter int
Debug bool
}
env.MustParse(&envs)
defines two environments, which can be set using any of
iter=1 debug=true ./example // debug is a boolean flag so its value is set to true
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrorFieldIsNotWritable field is not writable. ErrorFieldIsNotWritable = errors.New("field is not writable") // ErrorFieldIsRequired field is required. ErrorFieldIsRequired = errors.New("field is required") // ErrorNotPointers source is not pointers. ErrorNotPointers = errors.New("must be pointers") // ErrorNotStruct source is not structs. ErrorNotStruct = errors.New("must be structs") // ErrorRequiredWithDefault error when required used with default value. ErrorRequiredWithDefault = errors.New("'required' cannot be used when a default value is specified") // ErrorUnrecognizedTag unrecognized tag. ErrorUnrecognizedTag = errors.New("unrecognized tag") // ErrorFieldsAreNotSupported fields are not supported. ErrorFieldsAreNotSupported = errors.New("fields are not supported") // ErrorDefaultValueForSlice default value for slice are not supported. ErrorDefaultValueForSlice = errors.New("default values are not supported for slice fields") )
Functions ¶
Types ¶
type Described ¶
type Described interface {
// Description returns the string that will be printed on a line by itself
// at the top of the help message.
Description() string
}
Described is the interface that the destination struct should implement to make a description string appear at the top of the help message.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser represents a set of command line options with destination values.
Click to show internal directories.
Click to hide internal directories.