Documentation
¶
Index ¶
- func Get[T any](r *Repository, key string) T
- type Repository
- func (r *Repository) All() map[string]any
- func (r *Repository) Env(key string, defaultValue ...string) string
- func (r *Repository) GetBool(key string) bool
- func (r *Repository) GetFloat64(key string) float64
- func (r *Repository) GetInt(key string) int
- func (r *Repository) GetString(key string) string
- func (r *Repository) GetStringMap(key string) map[string]any
- func (r *Repository) GetStringSlice(key string) []string
- func (r *Repository) Has(key string) bool
- func (r *Repository) Load() error
- func (r *Repository) LoadFrom(configPath string) error
- func (r *Repository) Set(key string, value any)
- func (r *Repository) SetDefault(key string, value any)
- func (r *Repository) Unmarshal(rawVal any) error
- func (r *Repository) UnmarshalKey(key string, rawVal any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository 配置仓库
func (*Repository) Env ¶
func (r *Repository) Env(key string, defaultValue ...string) string
Env 获取环境变量
func (*Repository) GetFloat64 ¶
func (r *Repository) GetFloat64(key string) float64
GetFloat64 获取浮点数配置
func (*Repository) GetStringMap ¶
func (r *Repository) GetStringMap(key string) map[string]any
GetStringMap 获取字符串映射配置
func (*Repository) GetStringSlice ¶
func (r *Repository) GetStringSlice(key string) []string
GetStringSlice 获取字符串切片配置
func (*Repository) LoadFrom ¶
func (r *Repository) LoadFrom(configPath string) error
LoadFrom 从指定文件加载配置
func (*Repository) SetDefault ¶
func (r *Repository) SetDefault(key string, value any)
SetDefault 设置默认值
func (*Repository) UnmarshalKey ¶
func (r *Repository) UnmarshalKey(key string, rawVal any) error
UnmarshalKey 将指定键的配置解析到结构体
Click to show internal directories.
Click to hide internal directories.