Documentation
¶
Overview ¶
Package conf 提供最基础的配置加载功能
Index ¶
- Variables
- func GetBool(key string) bool
- func GetConfigPath() string
- func GetDuration(key string) time.Duration
- func GetFloat64(key string) float64
- func GetInt(key string) int
- func GetInt32(key string) int32
- func GetInt64(key string) int64
- func GetIntSlice(key string) (s []int64, err error)
- func GetProjectDBName(key1, key2 string) string
- func GetStrMapStr(key string) map[string]string
- func GetString(key string) string
- func GetStringSlice(key string) (s []string)
- func GetTime(key string, args ...string) time.Time
- func IsSet(key string) bool
- func OnConfigChange(run func())
- func Set(key string, value string)
- func WatchConfig()
Constants ¶
This section is empty.
Variables ¶
View Source
var ( BinBuildVersion = "" BinBuildCommit = "" BinBuildDate = "" BinAppName = "" )
View Source
var ( // Hostname 主机名 Hostname = "localhost" // AppID 获取 APP_ID AppID = "localapp" // 机器ID MachineID uint16 = 0 // IsDevEnv 开发环境标志 IsDevEnv = false // IsUatEnv 集成环境标志 IsUatEnv = false // IsProdEnv 生产环境标志 IsProdEnv = false // Env 运行环境 Env = "dev" // Zone 服务区域 Zone = "qd001" )
Functions ¶
func GetConfigPath ¶
func GetConfigPath() string
func GetIntSlice ¶
GetIntSlice 获取数字列表 1,2,3 => []int64{1,2,3}
func GetProjectDBName ¶
func GetStrMapStr ¶
func GetStringSlice ¶
GetStringSlice 获取字符串列表 a,b,c => []string{"a", "b", "c"}
func GetTime ¶
GetTime 查询时间配置 默认时间格式为 "2006-01-02 15:04:05",conf.GetTime("FOO_BEGIN") 如果需要指定时间格式,则可以多传一个参数,conf.GetString("FOO_BEGIN", "2006")
配置不存在或时间格式错误返回**空时间对象** 使用本地时区
func OnConfigChange ¶
func OnConfigChange(run func())
OnConfigChange 注册配置文件变更回调 需要在 WatchConfig 之前调用
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.