Documentation
¶
Index ¶
- type JSONConfig
- type JSONConfigContainer
- func (c *JSONConfigContainer) Bool(ctx context.Context, key string) (bool, error)
- func (c *JSONConfigContainer) DIY(ctx context.Context, key string) (v interface{}, err error)
- func (c *JSONConfigContainer) DefaultBool(ctx context.Context, key string, defaultVal bool) bool
- func (c *JSONConfigContainer) DefaultFloat(ctx context.Context, key string, defaultVal float64) float64
- func (c *JSONConfigContainer) DefaultInt(ctx context.Context, key string, defaultVal int) int
- func (c *JSONConfigContainer) DefaultInt64(ctx context.Context, key string, defaultVal int64) int64
- func (c *JSONConfigContainer) DefaultString(ctx context.Context, key string, defaultVal string) string
- func (c *JSONConfigContainer) DefaultStrings(ctx context.Context, key string, defaultVal []string) []string
- func (c *JSONConfigContainer) Float(ctx context.Context, key string) (float64, error)
- func (c *JSONConfigContainer) GetSection(ctx context.Context, section string) (map[string]string, error)
- func (c *JSONConfigContainer) Int(ctx context.Context, key string) (int, error)
- func (c *JSONConfigContainer) Int64(ctx context.Context, key string) (int64, error)
- func (c *JSONConfigContainer) OnChange(ctx context.Context, key string, fn func(value string))
- func (c *JSONConfigContainer) SaveConfigFile(ctx context.Context, filename string) (err error)
- func (c *JSONConfigContainer) Set(ctx context.Context, key, val string) error
- func (c *JSONConfigContainer) String(ctx context.Context, key string) (string, error)
- func (c *JSONConfigContainer) Strings(ctx context.Context, key string) ([]string, error)
- func (c *JSONConfigContainer) Sub(ctx context.Context, key string) (config.Configer, error)
- func (c *JSONConfigContainer) 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 JSONConfig ¶
type JSONConfig struct { }
JSONConfig is a json config parser and implements Config interface.
type JSONConfigContainer ¶
JSONConfigContainer is a config which represents the json configuration. Only when get value, support key as section:name type.
func (*JSONConfigContainer) DIY ¶
func (c *JSONConfigContainer) DIY(ctx context.Context, key string) (v interface{}, err error)
DIY returns the raw value by a given key.
func (*JSONConfigContainer) DefaultBool ¶
DefaultBool return the bool value if has no error otherwise return the defaultval
func (*JSONConfigContainer) DefaultFloat ¶
func (c *JSONConfigContainer) DefaultFloat(ctx context.Context, key string, defaultVal float64) float64
DefaultFloat returns the float64 value for a given key. if err != nil return defaultval
func (*JSONConfigContainer) DefaultInt ¶
DefaultInt returns the integer value for a given key. if err != nil return defaultval
func (*JSONConfigContainer) DefaultInt64 ¶
DefaultInt64 returns the int64 value for a given key. if err != nil return defaultval
func (*JSONConfigContainer) DefaultString ¶
func (c *JSONConfigContainer) DefaultString(ctx context.Context, key string, defaultVal string) string
DefaultString returns the string value for a given key. if err != nil return defaultval
func (*JSONConfigContainer) DefaultStrings ¶
func (c *JSONConfigContainer) DefaultStrings(ctx context.Context, key string, defaultVal []string) []string
DefaultStrings returns the []string value for a given key. if err != nil return defaultval
func (*JSONConfigContainer) GetSection ¶
func (c *JSONConfigContainer) GetSection(ctx context.Context, section string) (map[string]string, error)
GetSection returns map for the given section
func (*JSONConfigContainer) OnChange ¶
func (c *JSONConfigContainer) OnChange(ctx context.Context, key string, fn func(value string))
func (*JSONConfigContainer) SaveConfigFile ¶
func (c *JSONConfigContainer) SaveConfigFile(ctx context.Context, filename string) (err error)
SaveConfigFile save the config into file
func (*JSONConfigContainer) Set ¶
func (c *JSONConfigContainer) Set(ctx context.Context, key, val string) error
Set writes a new value for key.
func (*JSONConfigContainer) Unmarshaler ¶
func (c *JSONConfigContainer) Unmarshaler(ctx context.Context, prefix string, obj interface{}, opt ...config.DecodeOption) error