gcfg

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package gcfg provides reading, caching and managing for configuration files/contents.

Index

Constants

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

Variables

This section is empty.

Functions

func ClearContent

func ClearContent()

ClearContent removes all global configuration contents.

func GetContent

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

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

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

SetContent sets 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

func Instance(name ...string) *Config

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

func New

func New(file ...string) *Config

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

func (*Config) AddPath

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

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) Contains

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

func (*Config) Get

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

func (*Config) GetArray

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

func (*Config) GetBool

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

func (*Config) GetFileName

func (c *Config) GetFileName() string

GetFileName returns the default configuration file name.

func (*Config) GetFilePath

func (c *Config) GetFilePath(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) GetFloat32

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

func (*Config) GetFloat64

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

func (*Config) GetFloats

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

func (*Config) GetInt

func (c *Config) GetInt(pattern string, file ...string) 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) GetInterfaces

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

func (*Config) GetInts

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

func (*Config) GetMap

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

func (*Config) GetString

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

func (*Config) GetStrings

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

func (*Config) GetToStruct

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

func (*Config) GetUint

func (c *Config) GetUint(pattern string, file ...string) 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) GetVar

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

func (*Config) Reload

func (c *Config) Reload()

Deprecated. See Clear.

func (*Config) SetFileName

func (c *Config) SetFileName(name string)

SetFileName sets the default configuration file name.

func (*Config) SetPath

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

SetPath sets the configuration directory path for file search. The param <path> can be absolute or relative path, but absolute path is suggested.

func (*Config) SetViolenceCheck

func (c *Config) SetViolenceCheck(check bool)

SetViolenceCheck sets whether to perform level 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.

Jump to

Keyboard shortcuts

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