Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitConfig ¶
func InitConfig(out interface{})
Types ¶
type IYmlConfig ¶
type IYmlConfig interface {
ConfigFileChangeListen()
Clone(fileName string) IYmlConfig
Get(keyName string) interface{}
GetString(keyName string) string
GetBool(keyName string) bool
GetInt(keyName string) int
GetInt32(keyName string) int32
GetInt64(keyName string) int64
GetFloat64(keyName string) float64
GetDuration(keyName string) time.Duration
GetStringSlice(keyName string) []string
}
由于 vipver 包本身对于文件的变化事件有一个bug,相关事件会被回调两次 常年未彻底解决,相关的 issue 清单:https://github.com/spf13/viper/issues?q=OnConfigChange 设置一个内部全局变量,记录配置文件变化时的时间点,如果两次回调事件事件差小于1秒,我们认为是第二次回调事件,而不是人工修改配置文件 这样就避免了 viper 包的这个bug
var ConfigYml IYmlConfig
func CreateYamlFactory ¶
func CreateYamlFactory(fileName ...string) IYmlConfig
CreateYamlFactory 创建一个yaml配置文件工厂 参数设置为可变参数的文件名,这样参数就可以不需要传递,如果传递了多个,我们只取第一个参数作为配置文件名
Click to show internal directories.
Click to hide internal directories.