xml

package
Version: v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2014 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

package xml for config provider

depend on github.com/beego/x2j

go install github.com/beego/x2j

Usage: import(

_ "github.com/astaxie/beego/config/xml"
"github.com/astaxie/beego/config"

)

cnf, err := config.NewConfig("xml", "config.xml")

more docs http://beego.me/docs/module/config.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type XMLConfig

type XMLConfig struct{}

XmlConfig is a xml config parser and implements Config interface. xml configurations should be included in <config></config> tag. only support key/value pair as <key>value</key> as each item.

func (*XMLConfig) Parse

func (xc *XMLConfig) Parse(filename string) (config.ConfigContainer, error)

Parse returns a ConfigContainer with parsed xml config map.

func (*XMLConfig) ParseData added in v1.4.0

func (x *XMLConfig) ParseData(data []byte) (config.ConfigContainer, error)

type XMLConfigContainer

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

A Config represents the xml configuration.

func (*XMLConfigContainer) Bool

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

Bool returns the boolean value for a given key.

func (*XMLConfigContainer) DIY

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

DIY returns the raw value by a given key.

func (*XMLConfigContainer) DefaultBool added in v1.4.0

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

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

func (*XMLConfigContainer) DefaultFloat added in v1.4.0

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

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

func (*XMLConfigContainer) DefaultInt added in v1.4.0

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

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

func (*XMLConfigContainer) DefaultInt64 added in v1.4.0

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

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

func (*XMLConfigContainer) DefaultString added in v1.4.0

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

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

func (*XMLConfigContainer) DefaultStrings added in v1.4.0

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

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

func (*XMLConfigContainer) Float

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

Float returns the float value for a given key.

func (*XMLConfigContainer) GetSection added in v1.4.0

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

GetSection returns map for the given section

func (*XMLConfigContainer) Int

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

Int returns the integer value for a given key.

func (*XMLConfigContainer) Int64

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

Int64 returns the int64 value for a given key.

func (*XMLConfigContainer) SaveConfigFile added in v1.4.0

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

SaveConfigFile save the config into file

func (*XMLConfigContainer) Set

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

WriteValue writes a new value for key.

func (*XMLConfigContainer) String

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

String returns the string value for a given key.

func (*XMLConfigContainer) Strings

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

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

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL