Documentation ¶
Overview ¶
Package conf 提供最基础的配置加载功能
Index ¶
- Variables
- func Get(key string) string
- func GetBool(key string) bool
- func GetDuration(key string) time.Duration
- func GetFloat64(key string) float64
- func GetInt(key string) int
- func GetInt32(key string) int32
- func GetInt32s(key string) (s []int32, err error)
- func GetInt64(key string) int64
- func GetInt64s(key string) (s []int64, err error)
- func GetStrings(key string) (s []string)
- func GetTime(key string, args ...string) time.Time
- func OnConfigChange(run func())
- func Set(key string, value string)
- func WatchConfig()
- type Conf
- func (c *Conf) Get(key string) string
- func (c *Conf) GetBool(key string) bool
- func (c *Conf) GetDuration(key string) time.Duration
- func (c *Conf) GetFloat64(key string) float64
- func (c *Conf) GetInt(key string) int
- func (c *Conf) GetInt32(key string) int32
- func (c *Conf) GetInt32s(key string) (s []int32, err error)
- func (c *Conf) GetInt64(key string) int64
- func (c *Conf) GetInt64s(key string) (s []int64, err error)
- func (c *Conf) GetStrings(key string) (s []string)
- func (c *Conf) GetTime(key string, args ...string) time.Time
- func (c *Conf) Set(key string, value string)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Hostname 主机名 Hostname = "localhost" // AppID 获取 APP_ID AppID = "localapp" // IsDevEnv 开发环境标志 IsDevEnv = false // IsUatEnv 集成环境标志 IsUatEnv = false // IsProdEnv 生产环境标志 IsProdEnv = false // Env 运行环境 Env = "dev" // Zone 服务区域 Zone = "sh001" )
Functions ¶
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 ¶
type Conf ¶
type Conf struct {
// contains filtered or unexported fields
}
func (*Conf) GetFloat64 ¶
func (*Conf) GetStrings ¶
Click to show internal directories.
Click to hide internal directories.