config

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const HomeEnv = "cfg_dir"

Variables

View Source
var (
	CfgType = "yaml"
	CfgName = "config"
	CfgDir  = filepath.Join(xerror.PanicStr(filepath.Abs(filepath.Dir(""))), "."+version.Domain)
	CfgPath = ""
)

Functions

func Decode

func Decode(name string, fn interface{}) error

Decode decode config to *struct|callback(*struct)

func SetCfg added in v0.1.26

func SetCfg(c Config)

Types

type CfgMap added in v0.1.26

type CfgMap map[string]interface{}

func GetMap

func GetMap(keys ...string) CfgMap

GetMap 通过key获取配置map

func (CfgMap) Decode added in v0.1.26

func (t CfgMap) Decode(dst interface{}, opts ...func(cfg *DecoderConfig)) error

type Config

type Config interface {
	Decode(name string, fnOrPtr interface{}) error
	Get(key string) interface{}
	Set(string, interface{})
	GetString(key string) string
	GetMap(keys ...string) CfgMap
	AllKeys() []string
	MergeConfig(in io.Reader) error
	All() map[string]interface{}
}

func GetCfg

func GetCfg() Config

GetCfg 获取内存配置

type DecoderConfig added in v0.1.26

type DecoderConfig = mapstructure.DecoderConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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