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 files.

配置管理, 配置文件格式支持:json, xml, toml, yaml/yml

Index

Package Files

gcfg.go

Constants

const (
    DEFAULT_CONFIG_FILE = "config.toml" // 默认的配置管理文件名称
)

type Config Uses

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

配置管理对象

func New Uses

func New(path string, file ...string) *Config

生成一个配置管理对象

func (*Config) AddPath Uses

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

添加配置管理器的配置文件搜索路径

func (*Config) Get Uses

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

获取配置项,当不存在时返回nil

func (*Config) GetArray Uses

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

获得一个数组[]interface{},方便操作,不需要自己做类型转换 注意,如果获取的值不存在,或者类型与json类型不匹配,那么将会返回nil

func (*Config) GetBool Uses

func (c *Config) GetBool(pattern string, file ...string) bool

返回指定json中的bool

func (*Config) GetFilePath Uses

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

获取指定文件的绝对路径,默认获取默认的配置文件路径

func (*Config) GetFloat32 Uses

func (c *Config) GetFloat32(pattern string, file ...string) float32

返回指定json中的float32

func (*Config) GetFloat64 Uses

func (c *Config) GetFloat64(pattern string, file ...string) float64

返回指定json中的float64

func (*Config) GetFloats Uses

func (c *Config) GetFloats(pattern string, file ...string) []float64

func (*Config) GetInt Uses

func (c *Config) GetInt(pattern string, file ...string) int

返回指定json中的float64->int

func (*Config) GetInt16 Uses

func (c *Config) GetInt16(pattern string, file ...string) int16

func (*Config) GetInt32 Uses

func (c *Config) GetInt32(pattern string, file ...string) int32

func (*Config) GetInt64 Uses

func (c *Config) GetInt64(pattern string, file ...string) int64

func (*Config) GetInt8 Uses

func (c *Config) GetInt8(pattern string, file ...string) int8

func (*Config) GetInterfaces Uses

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

func (*Config) GetInts Uses

func (c *Config) GetInts(pattern string, file ...string) []int

func (*Config) GetMap Uses

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

获得一个键值对关联数组/哈希表,方便操作,不需要自己做类型转换 注意,如果获取的值不存在,或者类型与json类型不匹配,那么将会返回nil

func (*Config) GetString Uses

func (c *Config) GetString(pattern string, file ...string) string

返回指定json中的string

func (*Config) GetStrings Uses

func (c *Config) GetStrings(pattern string, file ...string) []string

func (*Config) GetToStruct Uses

func (c *Config) GetToStruct(pattern string, objPointer interface{}, file ...string) error

func (*Config) GetUint Uses

func (c *Config) GetUint(pattern string, file ...string) uint

返回指定json中的float64->uint

func (*Config) GetUint16 Uses

func (c *Config) GetUint16(pattern string, file ...string) uint16

func (*Config) GetUint32 Uses

func (c *Config) GetUint32(pattern string, file ...string) uint32

func (*Config) GetUint64 Uses

func (c *Config) GetUint64(pattern string, file ...string) uint64

func (*Config) GetUint8 Uses

func (c *Config) GetUint8(pattern string, file ...string) uint8

func (*Config) GetVar Uses

func (c *Config) GetVar(pattern string, file ...string) gvar.VarRead

获得配置项,返回动态变量

func (*Config) Reload Uses

func (c *Config) Reload()

清空当前配置文件缓存,强制重新从磁盘文件读取配置文件内容

func (*Config) SetFileName Uses

func (c *Config) SetFileName(name string)

设置配置管理对象的默认文件名称

func (*Config) SetPath Uses

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

设置配置管理器的配置文件存放目录绝对路径

func (*Config) SetViolenceCheck Uses

func (c *Config) SetViolenceCheck(check bool)

设置是否执行层级冲突检查,当键名中存在层级符号时需要开启该特性,默认为关闭。 开启比较耗性能,也不建议允许键名中存在分隔符,最好在应用端避免这种情况。

Package gcfg imports 12 packages (graph) and is imported by 3 packages. Updated 2019-02-04. Refresh now. Tools for package owners.