Documentation ¶
Overview ¶
Package gcfg provides reading, caching and managing for configuration.
Index ¶
- Constants
- func ClearContent()
- func GetContent(file ...string) string
- func RemoveConfig(file ...string)
- func SetContent(content string, file ...string)
- type Config
- func (c *Config) AddPath(path string) error
- func (c *Config) Clear()
- func (c *Config) Contains(pattern string) bool
- func (c *Config) Dump()
- func (c *Config) FilePath(file ...string) (path string)
- func (c *Config) Get(pattern string, def ...interface{}) interface{}
- func (c *Config) GetArray(pattern string, def ...interface{}) []interface{}
- func (c *Config) GetBool(pattern string, def ...interface{}) bool
- func (c *Config) GetBytes(pattern string, def ...interface{}) []byte
- func (c *Config) GetDuration(pattern string, def ...interface{}) time.Duration
- func (c *Config) GetFileName() string
- func (c *Config) GetFloat32(pattern string, def ...interface{}) float32
- func (c *Config) GetFloat64(pattern string, def ...interface{}) float64
- func (c *Config) GetFloats(pattern string, def ...interface{}) []float64
- func (c *Config) GetGTime(pattern string, format ...string) *gtime.Time
- func (c *Config) GetInt(pattern string, def ...interface{}) int
- func (c *Config) GetInt16(pattern string, def ...interface{}) int16
- func (c *Config) GetInt32(pattern string, def ...interface{}) int32
- func (c *Config) GetInt64(pattern string, def ...interface{}) int64
- func (c *Config) GetInt8(pattern string, def ...interface{}) int8
- func (c *Config) GetInterfaces(pattern string, def ...interface{}) []interface{}
- func (c *Config) GetInts(pattern string, def ...interface{}) []int
- func (c *Config) GetJson(pattern string, def ...interface{}) *gjson.Json
- func (c *Config) GetJsonMap(pattern string, def ...interface{}) map[string]*gjson.Json
- func (c *Config) GetJsons(pattern string, def ...interface{}) []*gjson.Json
- func (c *Config) GetMap(pattern string, def ...interface{}) map[string]interface{}
- func (c *Config) GetMapStruct(pattern string, pointer interface{}, mapping ...map[string]string) error
- func (c *Config) GetMapStructDeep(pattern string, pointer interface{}, mapping ...map[string]string) error
- func (c *Config) GetMapStructs(pattern string, pointer interface{}, mapping ...map[string]string) error
- func (c *Config) GetMapStructsDeep(pattern string, pointer interface{}, mapping ...map[string]string) error
- func (c *Config) GetString(pattern string, def ...interface{}) string
- func (c *Config) GetStrings(pattern string, def ...interface{}) []string
- func (c *Config) GetStruct(pattern string, pointer interface{}, mapping ...map[string]string) error
- func (c *Config) GetStructDeep(pattern string, pointer interface{}, mapping ...map[string]string) error
- func (c *Config) GetStructs(pattern string, pointer interface{}, mapping ...map[string]string) error
- func (c *Config) GetStructsDeep(pattern string, pointer interface{}, mapping ...map[string]string) error
- func (c *Config) GetTime(pattern string, format ...string) time.Time
- func (c *Config) GetUint(pattern string, def ...interface{}) uint
- func (c *Config) GetUint16(pattern string, def ...interface{}) uint16
- func (c *Config) GetUint32(pattern string, def ...interface{}) uint32
- func (c *Config) GetUint64(pattern string, def ...interface{}) uint64
- func (c *Config) GetUint8(pattern string, def ...interface{}) uint8
- func (c *Config) GetVar(pattern string, def ...interface{}) *gvar.Var
- func (c *Config) SetFileName(name string) *Config
- func (c *Config) SetPath(path string) error
- func (c *Config) SetViolenceCheck(check bool)
- func (c *Config) ToArray() []interface{}
- func (c *Config) ToMap() map[string]interface{}
- func (c *Config) ToMapStruct(pointer interface{}, mapping ...map[string]string) error
- func (c *Config) ToMapStructDeep(pointer interface{}, mapping ...map[string]string) error
- func (c *Config) ToMapStructs(pointer interface{}, mapping ...map[string]string) error
- func (c *Config) ToMapStructsDeep(pointer interface{}, mapping ...map[string]string) error
- func (c *Config) ToStruct(pointer interface{}, mapping ...map[string]string) error
- func (c *Config) ToStructDeep(pointer interface{}, mapping ...map[string]string) error
- func (c *Config) ToStructs(pointer interface{}, mapping ...map[string]string) error
- func (c *Config) ToStructsDeep(pointer interface{}, mapping ...map[string]string) error
Constants ¶
const (
// DEFAULT_CONFIG_FILE is the default configuration file name.
DEFAULT_CONFIG_FILE = "config.toml"
)
const (
// Default group name for instance usage.
DEFAULT_NAME = "default"
)
Variables ¶
This section is empty.
Functions ¶
func GetContent ¶
GetContent returns customized configuration content for specified <file>. The <file> is unnecessary param, default is DEFAULT_CONFIG_FILE.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Configuration struct.
func Instance ¶
Instance returns an instance of Config with default settings. The parameter <name> is the name for the instance.
func New ¶
New returns a new configuration management object. The parameter <file> specifies the default configuration file name for reading.
func (*Config) AddPath ¶
AddPath adds a absolute or relative path to the search paths.
func (*Config) Clear ¶
func (c *Config) Clear()
Clear removes all parsed configuration files content cache, which will force reload configuration content from file.
func (*Config) Dump ¶
func (c *Config) Dump()
Dump prints current Json object with more manually readable.
func (*Config) FilePath ¶
GetFilePath returns the absolute path of the specified configuration file. If <file> is not passed, it returns the configuration file path of the default name. If the specified configuration file does not exist, an empty string is returned.
func (*Config) GetArray ¶
func (*Config) GetDuration ¶
func (*Config) GetFileName ¶
GetFileName returns the default configuration file name.
func (*Config) GetInterfaces ¶
func (*Config) GetJsonMap ¶
func (*Config) GetJsons ¶
func (*Config) GetMap ¶
func (*Config) GetMapStruct ¶
func (*Config) GetMapStructDeep ¶
func (*Config) GetMapStructs ¶
func (*Config) GetMapStructsDeep ¶
func (*Config) GetStrings ¶
func (*Config) GetStruct ¶
func (*Config) GetStructDeep ¶
func (*Config) GetStructs ¶
func (*Config) GetStructsDeep ¶
func (*Config) SetFileName ¶
SetFileName sets the default configuration file name.
func (*Config) SetPath ¶
SetPath sets the configuration directory path for file search. The parameter <path> can be absolute or relative path, but absolute path is strongly recommended.
func (*Config) SetViolenceCheck ¶
SetViolenceCheck sets whether to perform hierarchical conflict check. This feature needs to be enabled when there is a level symbol in the key name. The default is off. Turning on this feature is quite expensive, and it is not recommended to allow separators in the key names. It is best to avoid this on the application side.