yaml

package
v1.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadYmlReader

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

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

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 added in v1.4.0

func (yaml *YAMLConfig) ParseData(data []byte) (config.ConfigContainer, error)

type YAMLConfigContainer

type YAMLConfigContainer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL