beego: github.com/astaxie/beego/config/yaml Index | Files

package yaml

import "github.com/astaxie/beego/config/yaml"

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

Package Files

yaml.go

func ReadYmlReader Uses

func ReadYmlReader(path string) (cnf map[string]interface{}, err error)

ReadYmlReader Read yaml file to map. if json like, use json package, unless goyaml2 package.

type Config Uses

type Config struct{}

Config is a yaml config parser and implements Config interface.

func (*Config) Parse Uses

func (yaml *Config) Parse(filename string) (y config.Configer, err error)

Parse returns a ConfigContainer with parsed yaml config map.

func (*Config) ParseData Uses

func (yaml *Config) ParseData(data []byte) (config.Configer, error)

ParseData parse yaml data

type ConfigContainer Uses

type ConfigContainer struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

ConfigContainer A Config represents the yaml configuration.

func (*ConfigContainer) Bool Uses

func (c *ConfigContainer) Bool(key string) (bool, error)

Bool returns the boolean value for a given key.

func (*ConfigContainer) DIY Uses

func (c *ConfigContainer) DIY(key string) (v interface{}, err error)

DIY returns the raw value by a given key.

func (*ConfigContainer) DefaultBool Uses

func (c *ConfigContainer) DefaultBool(key string, defaultval bool) bool

DefaultBool return the bool value if has no error otherwise return the defaultval

func (*ConfigContainer) DefaultFloat Uses

func (c *ConfigContainer) DefaultFloat(key string, defaultval float64) float64

DefaultFloat returns the float64 value for a given key. if err != nil return defaultval

func (*ConfigContainer) DefaultInt Uses

func (c *ConfigContainer) DefaultInt(key string, defaultval int) int

DefaultInt returns the integer value for a given key. if err != nil return defaultval

func (*ConfigContainer) DefaultInt64 Uses

func (c *ConfigContainer) DefaultInt64(key string, defaultval int64) int64

DefaultInt64 returns the int64 value for a given key. if err != nil return defaultval

func (*ConfigContainer) DefaultString Uses

func (c *ConfigContainer) DefaultString(key string, defaultval string) string

DefaultString returns the string value for a given key. if err != nil return defaultval

func (*ConfigContainer) DefaultStrings Uses

func (c *ConfigContainer) DefaultStrings(key string, defaultval []string) []string

DefaultStrings returns the []string value for a given key. if err != nil return defaultval

func (*ConfigContainer) Float Uses

func (c *ConfigContainer) Float(key string) (float64, error)

Float returns the float value for a given key.

func (*ConfigContainer) GetSection Uses

func (c *ConfigContainer) GetSection(section string) (map[string]string, error)

GetSection returns map for the given section

func (*ConfigContainer) Int Uses

func (c *ConfigContainer) Int(key string) (int, error)

Int returns the integer value for a given key.

func (*ConfigContainer) Int64 Uses

func (c *ConfigContainer) Int64(key string) (int64, error)

Int64 returns the int64 value for a given key.

func (*ConfigContainer) SaveConfigFile Uses

func (c *ConfigContainer) SaveConfigFile(filename string) (err error)

SaveConfigFile save the config into file

func (*ConfigContainer) Set Uses

func (c *ConfigContainer) Set(key, val string) error

Set writes a new value for key.

func (*ConfigContainer) String Uses

func (c *ConfigContainer) String(key string) string

String returns the string value for a given key.

func (*ConfigContainer) Strings Uses

func (c *ConfigContainer) Strings(key string) []string

Strings returns the []string value for a given key.

Package yaml imports 11 packages (graph) and is imported by 3 packages. Updated 2019-02-26. Refresh now. Tools for package owners.