config

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigFuncs map[string]ConfigFunc

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

Functions

func Add

func Add(name string, configFn ConfigFunc)

Add 新增配置项

func Env

func Env(envName string, defaultValue ...interface{}) interface{}

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

func Get

func Get(path string, defaultValue ...interface{}) string

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

func GetBool

func GetBool(path string, defaultValue ...interface{}) bool

GetBool 获取 Bool 类型的配置信息

func GetFloat64

func GetFloat64(path string, defaultValue ...interface{}) float64

GetFloat64 获取 float64 类型的配置信息

func GetInt

func GetInt(path string, defaultValue ...interface{}) int

GetInt 获取 Int 类型的配置信息

func GetInt64

func GetInt64(path string, defaultValue ...interface{}) int64

GetInt64 获取 Int64 类型的配置信息

func GetString

func GetString(path string, defaultValue ...interface{}) string

GetString 获取 String 类型的配置信息

func GetStringMapString

func GetStringMapString(path string) map[string]string

GetStringMapString 获取结构数据

func GetUint

func GetUint(path string, defaultValue ...interface{}) uint

GetUint 获取 Uint 类型的配置信息

Types

type ConfigFunc

type ConfigFunc func() map[string]interface{}

ConfigFunc 动态加载配置信息

Jump to

Keyboard shortcuts

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