Documentation ¶
Overview ¶
Package xml for config provider.
depend on github.com/beego/x2j.
go install github.com/beego/x2j.
Usage:
import( _ "github.com/flycash/beego-orm/config/xml" "github.com/flycash/beego-orm/config" ) cnf, err := config.NewConfig("xml", "config.xml")
More docs http://beego.me/docs/module/config.md
Index ¶
- type Config
- type ConfigContainer
- func (c *ConfigContainer) Bool(ctx context.Context, key string) (bool, error)
- func (c *ConfigContainer) DIY(ctx context.Context, key string) (v interface{}, err error)
- func (c *ConfigContainer) DefaultBool(ctx context.Context, key string, defaultVal bool) bool
- func (c *ConfigContainer) DefaultFloat(ctx context.Context, key string, defaultVal float64) float64
- func (c *ConfigContainer) DefaultInt(ctx context.Context, key string, defaultVal int) int
- func (c *ConfigContainer) DefaultInt64(ctx context.Context, key string, defaultVal int64) int64
- func (c *ConfigContainer) DefaultString(ctx context.Context, key string, defaultVal string) string
- func (c *ConfigContainer) DefaultStrings(ctx context.Context, key string, defaultVal []string) []string
- func (c *ConfigContainer) Float(ctx context.Context, key string) (float64, error)
- func (c *ConfigContainer) GetSection(ctx context.Context, section string) (map[string]string, error)
- func (c *ConfigContainer) Int(ctx context.Context, key string) (int, error)
- func (c *ConfigContainer) Int64(ctx context.Context, key string) (int64, error)
- func (c *ConfigContainer) OnChange(ctx context.Context, key string, fn func(value string))
- func (c *ConfigContainer) SaveConfigFile(ctx context.Context, filename string) (err error)
- func (c *ConfigContainer) Set(ctx context.Context, key, val string) error
- func (c *ConfigContainer) String(ctx context.Context, key string) (string, error)
- func (c *ConfigContainer) Strings(ctx context.Context, key string) ([]string, error)
- func (c *ConfigContainer) Sub(ctx context.Context, key string) (config.Configer, error)
- func (c *ConfigContainer) Unmarshaler(ctx context.Context, prefix string, obj interface{}, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct{}
Config 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.
type ConfigContainer ¶
ConfigContainer is a Config which represents the xml configuration.
func (*ConfigContainer) DIY ¶
func (c *ConfigContainer) DIY(ctx context.Context, key string) (v interface{}, err error)
DIY returns the raw value by a given key.
func (*ConfigContainer) DefaultBool ¶
DefaultBool return the bool value if has no error otherwise return the defaultVal
func (*ConfigContainer) DefaultFloat ¶
DefaultFloat returns the float64 value for a given key. if err != nil return defaultVal
func (*ConfigContainer) DefaultInt ¶
DefaultInt returns the integer value for a given key. if err != nil return defaultVal
func (*ConfigContainer) DefaultInt64 ¶
DefaultInt64 returns the int64 value for a given key. if err != nil return defaultVal
func (*ConfigContainer) DefaultString ¶
DefaultString returns the string value for a given key. if err != nil return defaultVal
func (*ConfigContainer) DefaultStrings ¶
func (c *ConfigContainer) DefaultStrings(ctx context.Context, key string, defaultVal []string) []string
DefaultStrings returns the []string value for a given key. if err != nil return defaultVal
func (*ConfigContainer) GetSection ¶
func (c *ConfigContainer) GetSection(ctx context.Context, section string) (map[string]string, error)
GetSection returns map for the given section
func (*ConfigContainer) OnChange ¶
func (c *ConfigContainer) OnChange(ctx context.Context, key string, fn func(value string))
func (*ConfigContainer) SaveConfigFile ¶
func (c *ConfigContainer) SaveConfigFile(ctx context.Context, filename string) (err error)
SaveConfigFile save the config into file
func (*ConfigContainer) Set ¶
func (c *ConfigContainer) Set(ctx context.Context, key, val string) error
Set writes a new value for key.
func (*ConfigContainer) Unmarshaler ¶
func (c *ConfigContainer) Unmarshaler(ctx context.Context, prefix string, obj interface{}, opt ...config.DecodeOption) error
Unmarshaler is a little be inconvenient since the xml library doesn't know type. So when you use <id>1</id> The "1" is a string, not int