Documentation
¶
Overview ¶
Package config 提供了加载配置项内容的各类方法
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("id 值已经存在")
ErrNotFound 未找到与 ID 相关的项
Functions ¶
Types ¶
type Config ¶ added in v0.32.0
type Config struct {
// contains filtered or unexported fields
}
Config 管理配置项的加载和刷新
func New ¶ added in v0.32.0
func New(config string, v interface{}, f UnmarshalFunc, notify func()) *Config
New 注册配置项
config 表示配置项的配置内容,比如文件名、SQL 的 DSN 等; v 配置项导出对象的实例指针,最终 config 指向的数据会被解析到 v 中; f 从 config 导入到 v 的实现方法; notify 如果后期需要更新数据,则通过此函数通知用户数据已经被更新;
type FieldError ¶ added in v0.32.0
type FieldError struct {
Field, Message string
}
FieldError 表示配置内容字段错误
func (*FieldError) Error ¶ added in v0.32.0
func (err *FieldError) Error() string
type UnmarshalFunc ¶
UnmarshalFunc 定义了配置项的解码函数原型
config 为配置项的配置内容,可以是一个文件名或是数据库的 DSN 等, UnmarshalFunc 负责将其指向的内容解析并映身到 v 对象。
Click to show internal directories.
Click to hide internal directories.