gf: github.com/gogf/gf/g/os/gcfg Index | Files

package gcfg

import "github.com/gogf/gf/g/os/gcfg"

Package gcfg provides reading, caching and managing for configuration.

Index

Package Files

gcfg.go gcfg_config.go gcfg_error.go gcfg_instance.go

Constants

const (
    // DEFAULT_CONFIG_FILE is the default configuration file name.
    DEFAULT_CONFIG_FILE = "config.toml"
)
const (
    // Default group name for instance usage.
    DEFAULT_GROUP_NAME = "default"
)

func ClearContent Uses

func ClearContent()

ClearContent removes all global configuration contents.

func GetContent Uses

func GetContent(file ...string) string

GetContent returns customized configuration content for specified <file>. The <file> is unnecessary param, default is DEFAULT_CONFIG_FILE.

func RemoveConfig Uses

func RemoveConfig(file ...string)

RemoveConfig removes the global configuration with specified group. If <name> is not passed, it removes configuration of the default group name.

func SetContent Uses

func SetContent(content string, file ...string)

SetContent sets customized configuration content for specified <file>. The <file> is unnecessary param, default is DEFAULT_CONFIG_FILE.

type Config Uses

type Config struct {
    // contains filtered or unexported fields
}

Configuration struct.

func Instance Uses

func Instance(name ...string) *Config

Instance returns an instance of Config with default settings. The parameter <name> is the name for the instance.

func New Uses

func New(file ...string) *Config

New returns a new configuration management object. The parameter <file> specifies the default configuration file name for reading.

func (*Config) AddPath Uses

func (c *Config) AddPath(path string) error

AddPath adds a absolute or relative path to the search paths.

func (*Config) Clear Uses

func (c *Config) Clear()

Clear removes all parsed configuration files content cache, which will force reload configuration content from file.

func (*Config) Contains Uses

func (c *Config) Contains(pattern string) bool

func (*Config) FilePath Uses

func (c *Config) FilePath(file ...string) (path string)

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) Get Uses

func (c *Config) Get(pattern string, def ...interface{}) interface{}

func (*Config) GetArray Uses

func (c *Config) GetArray(pattern string, def ...interface{}) []interface{}

func (*Config) GetBool Uses

func (c *Config) GetBool(pattern string, def ...interface{}) bool

func (*Config) GetDuration Uses

func (c *Config) GetDuration(pattern string, def ...interface{}) time.Duration

func (*Config) GetFileName Uses

func (c *Config) GetFileName() string

GetFileName returns the default configuration file name.

func (*Config) GetFilePath Uses

func (c *Config) GetFilePath(file ...string) (path string)

GetFilePath is alias of FilePath. Deprecated.

func (*Config) GetFloat32 Uses

func (c *Config) GetFloat32(pattern string, def ...interface{}) float32

func (*Config) GetFloat64 Uses

func (c *Config) GetFloat64(pattern string, def ...interface{}) float64

func (*Config) GetFloats Uses

func (c *Config) GetFloats(pattern string, def ...interface{}) []float64

func (*Config) GetGTime Uses

func (c *Config) GetGTime(pattern string, format ...string) *gtime.Time

func (*Config) GetInt Uses

func (c *Config) GetInt(pattern string, def ...interface{}) int

func (*Config) GetInt16 Uses

func (c *Config) GetInt16(pattern string, def ...interface{}) int16

func (*Config) GetInt32 Uses

func (c *Config) GetInt32(pattern string, def ...interface{}) int32

func (*Config) GetInt64 Uses

func (c *Config) GetInt64(pattern string, def ...interface{}) int64

func (*Config) GetInt8 Uses

func (c *Config) GetInt8(pattern string, def ...interface{}) int8

func (*Config) GetInterfaces Uses

func (c *Config) GetInterfaces(pattern string, def ...interface{}) []interface{}

func (*Config) GetInts Uses

func (c *Config) GetInts(pattern string, def ...interface{}) []int

func (*Config) GetMap Uses

func (c *Config) GetMap(pattern string, def ...interface{}) map[string]interface{}

func (*Config) GetString Uses

func (c *Config) GetString(pattern string, def ...interface{}) string

func (*Config) GetStrings Uses

func (c *Config) GetStrings(pattern string, def ...interface{}) []string

func (*Config) GetStruct Uses

func (c *Config) GetStruct(pattern string, pointer interface{}, mapping ...map[string]string) error

func (*Config) GetStructDeep Uses

func (c *Config) GetStructDeep(pattern string, pointer interface{}, mapping ...map[string]string) error

func (*Config) GetStructs Uses

func (c *Config) GetStructs(pattern string, pointer interface{}, mapping ...map[string]string) error

func (*Config) GetStructsDeep Uses

func (c *Config) GetStructsDeep(pattern string, pointer interface{}, mapping ...map[string]string) error

func (*Config) GetTime Uses

func (c *Config) GetTime(pattern string, format ...string) time.Time

func (*Config) GetToStruct Uses

func (c *Config) GetToStruct(pattern string, pointer interface{}) error

Deprecated.

func (*Config) GetUint Uses

func (c *Config) GetUint(pattern string, def ...interface{}) uint

func (*Config) GetUint16 Uses

func (c *Config) GetUint16(pattern string, def ...interface{}) uint16

func (*Config) GetUint32 Uses

func (c *Config) GetUint32(pattern string, def ...interface{}) uint32

func (*Config) GetUint64 Uses

func (c *Config) GetUint64(pattern string, def ...interface{}) uint64

func (*Config) GetUint8 Uses

func (c *Config) GetUint8(pattern string, def ...interface{}) uint8

func (*Config) GetVar Uses

func (c *Config) GetVar(pattern string, def ...interface{}) *gvar.Var

func (*Config) Reload Uses

func (c *Config) Reload()

Reload is alias of Clear. Deprecated.

func (*Config) SetFileName Uses

func (c *Config) SetFileName(name string)

SetFileName sets the default configuration file name.

func (*Config) SetPath Uses

func (c *Config) SetPath(path string) error

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 Uses

func (c *Config) SetViolenceCheck(check bool)

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.

Package gcfg imports 15 packages (graph) and is imported by 4 packages. Updated 2019-07-10. Refresh now. Tools for package owners.