Documentation ¶
Overview ¶
package yaml for config provider
depend on github.com/beego/goyaml2
go install github.com/beego/goyaml2
Usage: import(
_ "github.com/astaxie/beego/config/yaml" "github.com/astaxie/beego/config"
)
cnf, err := config.NewConfig("yaml", "config.yaml") more docs http://beego.me/docs/module/config.md
Index ¶
- func ReadYmlReader(path string) (cnf map[string]interface{}, err error)
- type YAMLConfig
- type YAMLConfigContainer
- func (c *YAMLConfigContainer) Bool(key string) (bool, error)
- func (c *YAMLConfigContainer) DIY(key string) (v interface{}, err error)
- func (c *YAMLConfigContainer) DefaultBool(key string, defaultval bool) bool
- func (c *YAMLConfigContainer) DefaultFloat(key string, defaultval float64) float64
- func (c *YAMLConfigContainer) DefaultInt(key string, defaultval int) int
- func (c *YAMLConfigContainer) DefaultInt64(key string, defaultval int64) int64
- func (c *YAMLConfigContainer) DefaultString(key string, defaultval string) string
- func (c *YAMLConfigContainer) DefaultStrings(key string, defaultval []string) []string
- func (c *YAMLConfigContainer) Float(key string) (float64, error)
- func (c *YAMLConfigContainer) GetSection(section string) (map[string]string, error)
- func (c *YAMLConfigContainer) Int(key string) (int, error)
- func (c *YAMLConfigContainer) Int64(key string) (int64, error)
- func (c *YAMLConfigContainer) SaveConfigFile(filename string) (err error)
- func (c *YAMLConfigContainer) Set(key, val string) error
- func (c *YAMLConfigContainer) String(key string) string
- func (c *YAMLConfigContainer) Strings(key string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type YAMLConfig ¶
type YAMLConfig struct{}
YAMLConfig is a yaml config parser and implements Config interface.
func (*YAMLConfig) Parse ¶
func (yaml *YAMLConfig) Parse(filename string) (y config.ConfigContainer, err error)
Parse returns a ConfigContainer with parsed yaml config map.
func (*YAMLConfig) ParseData ¶
func (yaml *YAMLConfig) ParseData(data []byte) (config.ConfigContainer, error)
type YAMLConfigContainer ¶
A Config represents the yaml configuration.
func (*YAMLConfigContainer) Bool ¶
func (c *YAMLConfigContainer) Bool(key string) (bool, error)
Bool returns the boolean value for a given key.
func (*YAMLConfigContainer) DIY ¶
func (c *YAMLConfigContainer) DIY(key string) (v interface{}, err error)
DIY returns the raw value by a given key.
func (*YAMLConfigContainer) DefaultBool ¶
func (c *YAMLConfigContainer) DefaultBool(key string, defaultval bool) bool
DefaultBool return the bool value if has no error otherwise return the defaultval
func (*YAMLConfigContainer) DefaultFloat ¶
func (c *YAMLConfigContainer) DefaultFloat(key string, defaultval float64) float64
DefaultFloat returns the float64 value for a given key. if err != nil return defaltval
func (*YAMLConfigContainer) DefaultInt ¶
func (c *YAMLConfigContainer) DefaultInt(key string, defaultval int) int
DefaultInt returns the integer value for a given key. if err != nil return defaltval
func (*YAMLConfigContainer) DefaultInt64 ¶
func (c *YAMLConfigContainer) DefaultInt64(key string, defaultval int64) int64
DefaultInt64 returns the int64 value for a given key. if err != nil return defaltval
func (*YAMLConfigContainer) DefaultString ¶
func (c *YAMLConfigContainer) DefaultString(key string, defaultval string) string
DefaultString returns the string value for a given key. if err != nil return defaltval
func (*YAMLConfigContainer) DefaultStrings ¶
func (c *YAMLConfigContainer) DefaultStrings(key string, defaultval []string) []string
DefaultStrings returns the []string value for a given key. if err != nil return defaltval
func (*YAMLConfigContainer) Float ¶
func (c *YAMLConfigContainer) Float(key string) (float64, error)
Float returns the float value for a given key.
func (*YAMLConfigContainer) GetSection ¶
func (c *YAMLConfigContainer) GetSection(section string) (map[string]string, error)
GetSection returns map for the given section
func (*YAMLConfigContainer) Int ¶
func (c *YAMLConfigContainer) Int(key string) (int, error)
Int returns the integer value for a given key.
func (*YAMLConfigContainer) Int64 ¶
func (c *YAMLConfigContainer) Int64(key string) (int64, error)
Int64 returns the int64 value for a given key.
func (*YAMLConfigContainer) SaveConfigFile ¶
func (c *YAMLConfigContainer) SaveConfigFile(filename string) (err error)
SaveConfigFile save the config into file
func (*YAMLConfigContainer) Set ¶
func (c *YAMLConfigContainer) Set(key, val string) error
WriteValue writes a new value for key.
func (*YAMLConfigContainer) String ¶
func (c *YAMLConfigContainer) String(key string) string
String returns the string value for a given key.
func (*YAMLConfigContainer) Strings ¶
func (c *YAMLConfigContainer) Strings(key string) []string
Strings returns the []string value for a given key.