Documentation ¶
Index ¶
- type Result
- type Type
- type YamlConfig
- func (this *YamlConfig) Bool(key string) (bool, error)
- func (this *YamlConfig) Exists(key string) bool
- func (this *YamlConfig) Float64(key string) (float64, error)
- func (this *YamlConfig) Get(path string) *Result
- func (this *YamlConfig) Int(key string) (int, error)
- func (this *YamlConfig) Map(key string) (map[interface{}]interface{}, error)
- func (this *YamlConfig) MustValue(key string, defaultVal ...string) string
- func (this *YamlConfig) Value(key string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct { // Type is the config type Type Type // Str is the config string Str string // Num is the config number Num float64 // Raw is unknow type value Raw interface{} }
Result represents a value that is returned from Get().
func (*Result) Int ¶
Int returns a int representation of the value. It returns 0 if error occurs, or the default value if given.
type YamlConfig ¶
type YamlConfig struct {
// contains filtered or unexported fields
}
YamlConfig represents a yaml configure. The root must be map.
func ParseYaml ¶
func ParseYaml(file string) (*YamlConfig, error)
ParseYaml parses yaml file into YamlConfig, return error (not nil) if failure.
func (*YamlConfig) Bool ¶
func (this *YamlConfig) Bool(key string) (bool, error)
Bool returns bool type value. It returns an error and false if the key does not exist.
func (*YamlConfig) Exists ¶
func (this *YamlConfig) Exists(key string) bool
Exists returns true if key exists.
func (*YamlConfig) Float64 ¶
func (this *YamlConfig) Float64(key string) (float64, error)
Float64 returns float64 type value. It returns an error and 0.0 if the key does not exist.
func (*YamlConfig) Get ¶
func (this *YamlConfig) Get(path string) *Result
Get returns bool type value. It returns an error and false if the key does not exist.
func (*YamlConfig) Int ¶
func (this *YamlConfig) Int(key string) (int, error)
Int returns int type value. It returns an error and 0 if the key does not exist.
func (*YamlConfig) Map ¶
func (this *YamlConfig) Map(key string) (map[interface{}]interface{}, error)
Map returns bool type value. It returns an error and false if the key does not exist.