config

package module
v0.0.0-...-07f7a80 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2021 License: MIT Imports: 10 Imported by: 0

README

config


封装了viper的相关使用,增加了 默认值的处理

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(key string, def ...interface{}) interface{}

Get can retrieve any value given the key to use.

func GetBool

func GetBool(key string, def ...bool) bool

func GetConfigPath

func GetConfigPath() string

func GetConfigType

func GetConfigType() string

func GetDefaultName

func GetDefaultName() string

func GetDuration

func GetDuration(key string, def ...interface{}) time.Duration

func GetInt

func GetInt(key string, def ...int) int

func GetInt16

func GetInt16(key string, def ...int16) int16

func GetInt32

func GetInt32(key string, def ...int32) int32

func GetInt64

func GetInt64(key string, def ...int64) int64

func GetInt8

func GetInt8(key string, def ...int8) int8

func GetIntSlice

func GetIntSlice(key string, def ...interface{}) []int

func GetSizeInBytes

func GetSizeInBytes(key string, def ...uint) uint

func GetString

func GetString(key string, def ...string) string

func GetStringMap

func GetStringMap(key string, def ...map[string]interface{}) map[string]interface{}

func GetStringMapString

func GetStringMapString(key string, def ...map[string]string) map[string]string

func GetStringMapStringSlice

func GetStringMapStringSlice(key string, def ...map[string][]string) map[string][]string

func GetStringSlice

func GetStringSlice(key string, def ...string) []string

func GetTime

func GetTime(key string, def ...interface{}) time.Time

func GetUint

func GetUint(key string, def ...uint) uint

func GetUint16

func GetUint16(key string, def ...uint16) uint16

func GetUint32

func GetUint32(key string, def ...uint32) uint32

func GetUint64

func GetUint64(key string, def ...uint64) uint64

func GetUint8

func GetUint8(key string, def ...uint8) uint8

func IsSet

func IsSet(key string) bool

func SetConfigPath

func SetConfigPath(p string)

func SetConfigType

func SetConfigType(t string)

func SetDefaultName

func SetDefaultName(name string)

Types

type Config

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

func Default

func Default() *Config

func Read

func Read(filename string) (c *Config)

func Use

func Use(name string) *Config

func (*Config) All

func (c *Config) All() map[string]interface{}

func (*Config) Get

func (c *Config) Get(key string, def ...interface{}) interface{}

func (*Config) GetBool

func (c *Config) GetBool(key string, def ...bool) bool

func (*Config) GetDuration

func (c *Config) GetDuration(key string, def ...interface{}) time.Duration

func (*Config) GetInt

func (c *Config) GetInt(key string, def ...int) int

func (*Config) GetInt16

func (c *Config) GetInt16(key string, def ...int16) int16

func (*Config) GetInt32

func (c *Config) GetInt32(key string, def ...int32) int32

func (*Config) GetInt64

func (c *Config) GetInt64(key string, def ...int64) int64

func (*Config) GetInt8

func (c *Config) GetInt8(key string, def ...int8) int8

func (*Config) GetIntSlice

func (c *Config) GetIntSlice(key string, def ...interface{}) []int

func (*Config) GetSizeInBytes

func (c *Config) GetSizeInBytes(key string, def ...uint) uint

func (*Config) GetString

func (c *Config) GetString(key string, def ...string) string

func (*Config) GetStringMap

func (c *Config) GetStringMap(key string, def ...map[string]interface{}) map[string]interface{}

func (*Config) GetStringMapString

func (c *Config) GetStringMapString(key string, def ...map[string]string) map[string]string

func (*Config) GetStringMapStringSlice

func (c *Config) GetStringMapStringSlice(key string, def ...map[string][]string) map[string][]string

func (*Config) GetStringSlice

func (c *Config) GetStringSlice(key string, def ...string) []string

func (*Config) GetTime

func (c *Config) GetTime(key string, def ...interface{}) time.Time

func (*Config) GetUint

func (c *Config) GetUint(key string, def ...uint) uint

func (*Config) GetUint16

func (c *Config) GetUint16(key string, def ...uint16) uint16

func (*Config) GetUint32

func (c *Config) GetUint32(key string, def ...uint32) uint32

func (*Config) GetUint64

func (c *Config) GetUint64(key string, def ...uint64) uint64

func (*Config) GetUint8

func (c *Config) GetUint8(key string, def ...uint8) uint8

func (*Config) IsSet

func (c *Config) IsSet(key string) bool

func (*Config) Keys

func (c *Config) Keys() []string

Jump to

Keyboard shortcuts

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