doconfig

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllSettings

func AllSettings() map[string]interface{}

func BindEnvConfig

func BindEnvConfig(prefix string, key string) error

绑定环境变量到配置

func BindPflagConfig

func BindPflagConfig(pflagKey string, cmdFlag *pflag.Flag)

绑定flag到配置

func Get

func Get(key string) interface{}

读取配置

func GetBool

func GetBool(key string) bool

func GetDuration

func GetDuration(key string) time.Duration

func GetFloat64

func GetFloat64(key string) float64

func GetInstance

func GetInstance() *viper.Viper

获取配置实例 可以直接调用配置库提供的方法

func GetInt

func GetInt(key string) int

func GetIntSlice

func GetIntSlice(key string) []int

func GetString

func GetString(key string) string

func GetStringMap

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

func GetStringMapString

func GetStringMapString(key string) map[string]string

func GetStringSlice

func GetStringSlice(key string) []string

func GetTime

func GetTime(key string) time.Time

func InitConfigs

func InitConfigs() error

读取默认的配置文件 配置文件位于./.sys/config.yaml

func IsSet

func IsSet(key string) bool

func LoadConfigs

func LoadConfigs(configName string, configType string, configPath string) error

加载配置文件 支持指定多个路径

func SafeWriteConfig

func SafeWriteConfig()

保存配置到文件

func SafeWriteConfigAs

func SafeWriteConfigAs(filePath string)

保存配置到指定文件

func Set

func Set(key string, val interface{})

func SetDefault

func SetDefault(key string, val interface{})

设置配置

func WriteConfig

func WriteConfig()

保存配置到文件

func WriteConfigAs

func WriteConfigAs(filePath string)

保存配置到指定文件

Types

This section is empty.

Jump to

Keyboard shortcuts

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