Documentation
¶
Index ¶
- type Config
- type ConfigurationMap
- func (c *ConfigurationMap) Bool(key string) (bool, error)
- func (c *ConfigurationMap) Exists(key string) bool
- func (c *ConfigurationMap) Float(key string) (float64, error)
- func (c *ConfigurationMap) FloatSlice(key string) ([]float64, error)
- func (c *ConfigurationMap) Int(key string) (int, error)
- func (c *ConfigurationMap) IntSlice(key string) ([]int, error)
- func (c *ConfigurationMap) Length(key string) (int, error)
- func (c *ConfigurationMap) String(key string) string
- func (c *ConfigurationMap) StringSlice(key string) []string
- type MultiConfig
- type ParseError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func Parse ¶
read and parse the configuration from the reader, return a Config struct, if there is an error during reading, return an error
func (*Config) ExistsValue ¶
return true if the key exists, otherwise return false
type ConfigurationMap ¶ added in v1.1.0
type ConfigurationMap struct {
// contains filtered or unexported fields
}
Recommended to use ConfigurationMap instead of MultiConfig or Config. The ConfigurationMap struct has unified functions to get value, get multiple values, check if key exists, and it can handle both single and multiple values for the same key.
func ParseConfig ¶ added in v1.1.0
func ParseConfig(r io.Reader) (*ConfigurationMap, error)
Read and parse the configuration through the io.Reader, return a ConfigurationMap struct. If there is an error during reading, return a ParseError struct which contains the line number and the error message. The ConfigurationMap struct should support multiple values for the same key.
func (*ConfigurationMap) Bool ¶ added in v1.1.0
func (c *ConfigurationMap) Bool(key string) (bool, error)
Return the value which is associated with the key and is converted to bool, if the key does not exist or the value cannot be converted to bool, return error. Multiple values for the same key are not allowed for boolean values, if there are multiple values, return error.
func (*ConfigurationMap) Exists ¶ added in v1.1.0
func (c *ConfigurationMap) Exists(key string) bool
Return true if the key exists, otherwise return false
func (*ConfigurationMap) Float ¶ added in v1.1.0
func (c *ConfigurationMap) Float(key string) (float64, error)
Return the value which is associated with the key and is converted to float, if the key does not exist or the value cannot be converted to float, return error. If there are multiple values for the same key, return the first value.
func (*ConfigurationMap) FloatSlice ¶ added in v1.1.0
func (c *ConfigurationMap) FloatSlice(key string) ([]float64, error)
Return a slice of floats which are associated with the key, if the key does not exist, return an empty slice. If there is an error, return an error.
func (*ConfigurationMap) Int ¶ added in v1.1.0
func (c *ConfigurationMap) Int(key string) (int, error)
Return the value which is associated with the key and is converted to int, if the key does not exist or the value cannot be converted to int, return error. If there are multiple values for the same key, return the first value.
func (*ConfigurationMap) IntSlice ¶ added in v1.1.0
func (c *ConfigurationMap) IntSlice(key string) ([]int, error)
Return a slice of integers which are associated with the key, if the key does not exist, return an empty slice.
func (*ConfigurationMap) Length ¶ added in v1.1.0
func (c *ConfigurationMap) Length(key string) (int, error)
Return the number of values which are associated with the key, if the key does not exist, return 0. If there is an error, return an error.
func (*ConfigurationMap) String ¶ added in v1.1.0
func (c *ConfigurationMap) String(key string) string
Return the value which is associated with the key, if the key does not exist, return empty string. If there are multiple values for the same key, return the first value.
func (*ConfigurationMap) StringSlice ¶ added in v1.1.0
func (c *ConfigurationMap) StringSlice(key string) []string
Return a slice of strings which are associated with the key, if the key does not exist, return an empty slice
type MultiConfig ¶ added in v1.0.0
type MultiConfig struct {
// contains filtered or unexported fields
}
func ParseMultipleValues ¶ added in v1.0.0
func ParseMultipleValues(r io.Reader) (*MultiConfig, error)
read and parse the configuration from the reader, return a MultiConfig struct, if there is an error during reading, return an error. The MultiConfig struct should support multiple values for the same key, and the values should be stored in a slice of strings.
func (*MultiConfig) ExistsMultipleValues ¶ added in v1.0.1
func (c *MultiConfig) ExistsMultipleValues(key string) bool
return true if the key exists, otherwise return false
func (*MultiConfig) GetFirstValue ¶ added in v1.0.1
func (c *MultiConfig) GetFirstValue(key string) string
return the first value which is associated with the key, if the key does not exist, return empty string
func (*MultiConfig) GetMultipleValues ¶ added in v1.0.1
func (c *MultiConfig) GetMultipleValues(key string) []string
return a slice of strings which are associated with the key, if the key does not exist, return an empty slice
type ParseError ¶ added in v1.1.0
type ParseError struct {
// contains filtered or unexported fields
}
func (*ParseError) Error ¶ added in v1.1.0
func (err *ParseError) Error() string