Documentation ¶
Index ¶
- func GetDefaultValue(kind reflect.Kind) any
- func GetPointerKind(t reflect.Type) reflect.Kind
- func ParseByteConfig(value interface{}, b []byte) error
- func ParseConfig(value interface{}, filename string) error
- func ParseStringConfig(value interface{}, strValue string) error
- func SetDefaultValue(field reflect.Value, kind reflect.Kind)
- type ChainMap
- type Config
- type ConfigParser
- func NewConfigParser() *ConfigParser
- func NewConfigParserFromFile(filename string) (*ConfigParser, error)
- func NewWithDefaults(defaults Dict) *ConfigParser
- func Parse(filename string) (*ConfigParser, error)
- func ParseBytes(b []byte) (*ConfigParser, error)
- func ParseString(value string) (*ConfigParser, error)
- func (p *ConfigParser) Defaults() Dict
- func (p *ConfigParser) Get(section, option string) (string, error)
- func (p *ConfigParser) GetBool(section, option string) (bool, error)
- func (p *ConfigParser) GetComplex128(section, option string) (complex128, error)
- func (p *ConfigParser) GetFloat64(section, option string) (float64, error)
- func (p *ConfigParser) GetInt64(section, option string) (int64, error)
- func (p *ConfigParser) GetIntSlice(section, option string) ([]int64, error)
- func (p *ConfigParser) GetRune(section, option string) rune
- func (p *ConfigParser) GetStringSlice(section, option string) ([]string, error)
- func (p *ConfigParser) HasOption(section, option string) (bool, error)
- func (p *ConfigParser) HasSection(section string) bool
- func (p *ConfigParser) Items(section string) (Dict, error)
- func (p *ConfigParser) ItemsWithDefaults(section string) (Dict, error)
- func (p *ConfigParser) Options(section string) ([]string, error)
- func (p *ConfigParser) RemoveOption(section, option string) error
- func (p *ConfigParser) Sections() []string
- func (p *ConfigParser) Set(section, option, value string) error
- type Dict
- type InvalidParseError
- type Section
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultValue ¶ added in v1.0.13
func ParseByteConfig ¶
func ParseConfig ¶
func ParseStringConfig ¶
Types ¶
type ChainMap ¶
type ChainMap struct {
// contains filtered or unexported fields
}
func NewChainMap ¶
type ConfigParser ¶
type ConfigParser struct {
// contains filtered or unexported fields
}
ConfigParser ties together a Config and default values for use in interpolated configuration values.
func NewConfigParserFromFile ¶
func NewConfigParserFromFile(filename string) (*ConfigParser, error)
NewConfigParserFromFile creates a new ConfigParser struct populated from the supplied filename.
func NewWithDefaults ¶
func NewWithDefaults(defaults Dict) *ConfigParser
NewWithDefaults allows creation of a new ConfigParser with a pre-existing Dict.
func Parse ¶
func Parse(filename string) (*ConfigParser, error)
Parse takes a filename and parses it into a ConfigParser value.
func ParseBytes ¶
func ParseBytes(b []byte) (*ConfigParser, error)
ParseBytes takes bytes array and parses it into a ConfigParser value.
func ParseString ¶
func ParseString(value string) (*ConfigParser, error)
ParseBytes takes bytes array and parses it into a ConfigParser value.
func (*ConfigParser) Defaults ¶
func (p *ConfigParser) Defaults() Dict
Defaults returns the items in the map used for default values.
func (*ConfigParser) Get ¶
func (p *ConfigParser) Get(section, option string) (string, error)
Get returns string value for the named option.
Returns an error if a section does not exist Returns an error if the option does not exist either in the section or in the defaults
func (*ConfigParser) GetComplex128 ¶
func (p *ConfigParser) GetComplex128(section, option string) (complex128, error)
func (*ConfigParser) GetFloat64 ¶
func (p *ConfigParser) GetFloat64(section, option string) (float64, error)
func (*ConfigParser) GetInt64 ¶
func (p *ConfigParser) GetInt64(section, option string) (int64, error)
func (*ConfigParser) GetIntSlice ¶
func (p *ConfigParser) GetIntSlice(section, option string) ([]int64, error)
func (*ConfigParser) GetRune ¶ added in v1.0.9
func (p *ConfigParser) GetRune(section, option string) rune
func (*ConfigParser) GetStringSlice ¶
func (p *ConfigParser) GetStringSlice(section, option string) ([]string, error)
func (*ConfigParser) HasOption ¶
func (p *ConfigParser) HasOption(section, option string) (bool, error)
func (*ConfigParser) HasSection ¶
func (p *ConfigParser) HasSection(section string) bool
HasSection returns true if the named section is present in the configuration.
The DEFAULT section is not acknowledged.
func (*ConfigParser) Items ¶
func (p *ConfigParser) Items(section string) (Dict, error)
Items returns a copy of the section Dict not including the Defaults.
NOTE: This is different from the Python version which returns a list of tuples
func (*ConfigParser) ItemsWithDefaults ¶
func (p *ConfigParser) ItemsWithDefaults(section string) (Dict, error)
ItemsWithDefaults returns a copy of the named section Dict including any values from the Defaults.
NOTE: This is different from the Python version which returns a list of tuples
func (*ConfigParser) Options ¶
func (p *ConfigParser) Options(section string) ([]string, error)
Options returns a list of option names for the given section name.
Returns an error if the section does not exist.
func (*ConfigParser) RemoveOption ¶
func (p *ConfigParser) RemoveOption(section, option string) error
func (*ConfigParser) Sections ¶
func (p *ConfigParser) Sections() []string
Sections returns a list of section names, excluding [DEFAULT].
func (*ConfigParser) Set ¶
func (p *ConfigParser) Set(section, option, value string) error
Set puts the given option into the named section.
Returns an error if the section does not exist.
type InvalidParseError ¶
InvalidParseError describes an invalid argument passed to ParseConfig. (The argument to ParseConfig must be a non-nil pointer.)
func (*InvalidParseError) Error ¶
func (e *InvalidParseError) Error() string