config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FuncList map[string]Func

FuncList 先加载到此数组,loadConfig 在动态生成配置信息

Functions

func Add

func Add(name string, configFn Func)

Add 新增配置项

func Env

func Env(envName string, defaultValue ...any) any

Env 读取环境变量,支持默认值

func Get

func Get(path string, defaultValue ...any) string

Get 获取配置项 第一个参数 path 允许使用点式获取,如:app.name 第二个参数允许传参默认值

func GetBool

func GetBool(path string, defaultValue ...any) bool

GetBool 获取 Bool 类型的配置信息

func GetFloat64

func GetFloat64(path string, defaultValue ...any) float64

GetFloat64 获取 float64 类型的配置信息

func GetInt

func GetInt(path string, defaultValue ...any) int

GetInt 获取 Int 类型的配置信息

func GetInt64

func GetInt64(path string, defaultValue ...any) int64

GetInt64 获取 Int64 类型的配置信息

func GetString

func GetString(path string, defaultValue ...any) string

GetString 获取 String 类型的配置信息

func GetStringMapString

func GetStringMapString(path string) map[string]string

GetStringMapString 获取结构数据

func GetUint

func GetUint(path string, defaultValue ...any) uint

GetUint 获取 Uint 类型的配置信息

func InitConfig

func InitConfig(env string)

InitConfig 初始化配置信息,完成对环境变量以及 conf 信息的加载

Types

type Func

type Func func() map[string]any

Func 动态加载配置信息

Jump to

Keyboard shortcuts

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