Documentation
¶
Index ¶
- func GetConfigValue[T any](key string, defaultValue T) T
- func IsProduction() bool
- func SetGlobalConfig(c *ConfigComponent)
- type ConfigComponent
- func (c *ConfigComponent) Get(key string) interface{}
- func (c *ConfigComponent) GetBool(key string) bool
- func (c *ConfigComponent) GetInt(key string) int
- func (c *ConfigComponent) GetSrtingTimeDuration(key string) time.Duration
- func (c *ConfigComponent) GetString(key string) string
- func (c *ConfigComponent) GetStringMap(key string) map[string]any
- func (c *ConfigComponent) GetStringSlice(key string) []string
- func (c *ConfigComponent) GetViper() *viper.Viper
- func (c *ConfigComponent) Load() error
- func (c *ConfigComponent) Unmarshal(rawVal interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConfigValue ¶
@title 获取配置值, 独立方法 @description 获取配置值,如果配置不存在则返回默认值 @param key string 配置名 @param defaultValue interface{} any @return interface{} any
Types ¶
type ConfigComponent ¶
type ConfigComponent struct {
// contains filtered or unexported fields
}
ConfigComponent 配置组件
func MustLoad ¶
func MustLoad(confName, confPath string) *ConfigComponent
MustLoad 创建并加载配置,如果出错则panic
func (*ConfigComponent) GetSrtingTimeDuration ¶
func (c *ConfigComponent) GetSrtingTimeDuration(key string) time.Duration
func (*ConfigComponent) GetString ¶
func (c *ConfigComponent) GetString(key string) string
GetString 获取字符串配置
func (*ConfigComponent) GetStringMap ¶
func (c *ConfigComponent) GetStringMap(key string) map[string]any
func (*ConfigComponent) GetStringSlice ¶
func (c *ConfigComponent) GetStringSlice(key string) []string
func (*ConfigComponent) GetViper ¶
func (c *ConfigComponent) GetViper() *viper.Viper
GetViper 获取Viper实例
func (*ConfigComponent) Unmarshal ¶
func (c *ConfigComponent) Unmarshal(rawVal interface{}) error
Unmarshal 将配置反序列化到结构体
Click to show internal directories.
Click to hide internal directories.