config

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](r *Repository, key string) T

Get 获取配置值(泛型版本)

Types

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository 配置仓库

func New

func New() *Repository

New 创建新的配置仓库

func (*Repository) All

func (r *Repository) All() map[string]any

All 获取所有配置

func (*Repository) Env

func (r *Repository) Env(key string, defaultValue ...string) string

Env 获取环境变量

func (*Repository) GetBool

func (r *Repository) GetBool(key string) bool

GetBool 获取布尔配置

func (*Repository) GetFloat64

func (r *Repository) GetFloat64(key string) float64

GetFloat64 获取浮点数配置

func (*Repository) GetInt

func (r *Repository) GetInt(key string) int

GetInt 获取整数配置

func (*Repository) GetString

func (r *Repository) GetString(key string) string

GetString 获取字符串配置

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) Has

func (r *Repository) Has(key string) bool

Has 检查配置是否存在

func (*Repository) Load

func (r *Repository) Load() error

Load 加载配置文件

func (*Repository) LoadFrom

func (r *Repository) LoadFrom(configPath string) error

LoadFrom 从指定文件加载配置

func (*Repository) Set

func (r *Repository) Set(key string, value any)

Set 设置配置值

func (*Repository) SetDefault

func (r *Repository) SetDefault(key string, value any)

SetDefault 设置默认值

func (*Repository) Unmarshal

func (r *Repository) Unmarshal(rawVal any) error

Unmarshal 将配置解析到结构体

func (*Repository) UnmarshalKey

func (r *Repository) UnmarshalKey(key string, rawVal any) error

UnmarshalKey 将指定键的配置解析到结构体

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL