conf

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: Apache-2.0 Imports: 11 Imported by: 140

Documentation

Index

Constants

View Source
const (
	StringType     = "string"
	IntType        = "int"
	Int64Type      = "int64"
	Int32Type      = "int32"
	BoolType       = "bool"
	StringListType = "[]string"
	AliasMapType   = "[string string, string]"
)

conf types

Variables

View Source
var (
	NL  = []byte{'\n'}
	ANT = []byte{'#'}
)
View Source
var ErrHomeNotFound = errors.New("$HOME not found")

Functions

func ErrConfKeyType

func ErrConfKeyType(key, dataType string) error

func ErrConfMissingKey

func ErrConfMissingKey(key, dataType string) error

func ErrMissConfigAliasMap

func ErrMissConfigAliasMap() error

func GetConfigDir

func GetConfigDir(app string) (dir string, err error)

func GetEnv added in v1.5.4

func GetEnv(env string) string

parse ${ENV} to ENV get ENV value from os

func GetEnvValue added in v1.5.4

func GetEnvValue(envName string) (string, error)

func GetStringList added in v1.5.4

func GetStringList(value string) []string

func Init

func Init(cflag, app, defaultConf string)

func IsEnv added in v1.5.4

func IsEnv(env string) (string, bool)

func Load

func Load(conf interface{}) error

func LoadEx

func LoadEx(conf interface{}, confName string) error

func LoadFile

func LoadFile(conf interface{}, confName string) (err error)

Types

type AliasKey

type AliasKey struct {
	Key   string
	Alias string
}

type MapConf

type MapConf map[string]string

MapConf 基于Map的配置信息

func DeepCopy added in v1.5.4

func DeepCopy(value MapConf) MapConf

func (MapConf) Get

func (conf MapConf) Get(key string) (interface{}, error)

func (MapConf) GetAliasList

func (c MapConf) GetAliasList(key string) (aks []AliasKey, err error)

func (MapConf) GetAliasMap

func (conf MapConf) GetAliasMap(key string) (map[string]string, error)

func (MapConf) GetAliasMapOr

func (conf MapConf) GetAliasMapOr(key string, deft map[string]string) (map[string]string, error)

func (MapConf) GetBool

func (conf MapConf) GetBool(key string) (bool, error)

func (MapConf) GetBoolOr

func (conf MapConf) GetBoolOr(key string, deft bool) (bool, error)

func (MapConf) GetInt

func (conf MapConf) GetInt(key string) (int, error)

func (MapConf) GetInt32 added in v1.5.3

func (conf MapConf) GetInt32(key string) (int32, error)

func (MapConf) GetInt32Or added in v1.5.3

func (conf MapConf) GetInt32Or(key string, deft int32) (int32, error)

func (MapConf) GetInt64

func (conf MapConf) GetInt64(key string) (int64, error)

func (MapConf) GetInt64Or

func (conf MapConf) GetInt64Or(key string, deft int64) (int64, error)

func (MapConf) GetIntOr

func (conf MapConf) GetIntOr(key string, deft int) (int, error)

func (MapConf) GetPasswordEnvString added in v1.5.4

func (conf MapConf) GetPasswordEnvString(key string) (string, error)

func (MapConf) GetPasswordEnvStringOr added in v1.5.4

func (conf MapConf) GetPasswordEnvStringOr(key, deft string) (string, error)

func (MapConf) GetString

func (conf MapConf) GetString(key string) (string, error)

func (MapConf) GetStringList

func (conf MapConf) GetStringList(key string) ([]string, error)

func (MapConf) GetStringListOr

func (conf MapConf) GetStringListOr(key string, deft []string) ([]string, error)

func (MapConf) GetStringOr

func (conf MapConf) GetStringOr(key string, deft string) (string, error)

Jump to

Keyboard shortcuts

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