gcfg

package
v0.0.0-...-c9a36a8 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

配置管理对象

func New

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

生成一个配置管理对象

func (*Config) AddPath

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

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

func (*Config) Close

func (c *Config) Close()

关闭Config对象,自动关闭异步协程

func (*Config) Get

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

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

func (*Config) GetArray

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

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

func (*Config) GetBool

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

返回指定json中的bool

func (*Config) GetFilePath

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

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

func (*Config) GetFloat32

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

返回指定json中的float32

func (*Config) GetFloat64

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

返回指定json中的float64

func (*Config) GetInt

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

返回指定json中的float64->int

func (*Config) GetInt16

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

func (*Config) GetInt32

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

func (*Config) GetInt64

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

func (*Config) GetInt8

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

func (*Config) GetMap

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

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

func (*Config) GetString

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

返回指定json中的string

func (*Config) GetUint

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

返回指定json中的float64->uint

func (*Config) GetUint16

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

func (*Config) GetUint32

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

func (*Config) GetUint64

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

func (*Config) GetUint8

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

func (*Config) Reload

func (c *Config) Reload()

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

func (*Config) SetFileName

func (c *Config) SetFileName(name string)

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

func (*Config) SetPath

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

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

Jump to

Keyboard shortcuts

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