json

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

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.

func (*JSONConfig) Parse

func (js *JSONConfig) Parse(filename string) (config.Configer, error)

Parse returns a ConfigContainer with parsed json config map.

func (*JSONConfig) ParseData

func (js *JSONConfig) ParseData(data []byte) (config.Configer, error)

ParseData returns a ConfigContainer with json string

type JSONConfigContainer

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

JSONConfigContainer is a config which represents the json configuration. Only when get value, support key as section:name type.

func (*JSONConfigContainer) Bool

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

Bool returns the boolean value for a given key.

func (*JSONConfigContainer) DIY

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

DIY returns the raw value by a given key.

func (*JSONConfigContainer) DefaultBool

func (c *JSONConfigContainer) DefaultBool(key string, defaultVal bool) bool

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

func (*JSONConfigContainer) DefaultFloat

func (c *JSONConfigContainer) DefaultFloat(key string, defaultVal float64) float64

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

func (*JSONConfigContainer) DefaultInt

func (c *JSONConfigContainer) DefaultInt(key string, defaultVal int) int

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

func (*JSONConfigContainer) DefaultInt64

func (c *JSONConfigContainer) DefaultInt64(key string, defaultVal int64) int64

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

func (*JSONConfigContainer) DefaultString

func (c *JSONConfigContainer) DefaultString(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(key string, defaultVal []string) []string

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

func (*JSONConfigContainer) Float

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

Float returns the float value for a given key.

func (*JSONConfigContainer) GetSection

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

GetSection returns map for the given section

func (*JSONConfigContainer) Int

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

Int returns the integer value for a given key.

func (*JSONConfigContainer) Int64

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

Int64 returns the int64 value for a given key.

func (*JSONConfigContainer) OnChange

func (c *JSONConfigContainer) OnChange(key string, fn func(value string))

func (*JSONConfigContainer) SaveConfigFile

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

SaveConfigFile save the config into file

func (*JSONConfigContainer) Set

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

Set writes a new value for key.

func (*JSONConfigContainer) String

func (c *JSONConfigContainer) String(key string) (string, error)

String returns the string value for a given key.

func (*JSONConfigContainer) Strings

func (c *JSONConfigContainer) Strings(key string) ([]string, error)

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

func (*JSONConfigContainer) Sub

func (*JSONConfigContainer) Unmarshaler

func (c *JSONConfigContainer) Unmarshaler(prefix string, obj interface{}, opt ...config.DecodeOption) error

Jump to

Keyboard shortcuts

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