config

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: MIT Imports: 4 Imported by: 0

README

go-config

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(name string, configuration map[string]interface{})

Add 新增配置项

func Env

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

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

func Get

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

Get 获取配置项,允许使用点式获取,如:app.name

func GetBool

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

func GetDuration added in v0.2.1

func GetDuration(key string, defaultValue ...interface{}) time.Duration

func GetFloat64 added in v0.2.1

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

func GetInt

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

GetInt 获取 Int 类型的配置信息

func GetInt32 added in v0.2.1

func GetInt32(key string, defaultValue ...interface{}) int32

func GetInt64

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

GetInt64 获取 Int64 类型的配置信息

func GetIntSlice added in v0.2.1

func GetIntSlice(key string, defaultValue ...interface{}) []int

func GetString

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

GetString 获取 String 类型的配置信息

func GetStringMap added in v0.2.1

func GetStringMap(key string, defaultValue ...interface{}) map[string]interface{}

func GetStringMapString added in v0.2.1

func GetStringMapString(key string, defaultValue ...interface{}) map[string]string

func GetStringMapStringSlice added in v0.2.1

func GetStringMapStringSlice(key string, defaultValue ...interface{}) map[string][]string

func GetStringSlice added in v0.2.1

func GetStringSlice(key string, defaultValue ...interface{}) []string

func GetTime added in v0.2.1

func GetTime(key string, defaultValue ...interface{}) time.Time

func GetUint

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

GetUint 获取 Uint 类型的配置信息

func GetUint16 added in v0.2.1

func GetUint16(key string, defaultValue ...interface{}) uint16

func GetUint32 added in v0.2.1

func GetUint32(key string, defaultValue ...interface{}) uint32

func GetUint64 added in v0.2.1

func GetUint64(key string, defaultValue ...interface{}) uint64

func Reload added in v0.2.0

func Reload() error

Reload 重新加载配置

func Set

func Set(name string, value interface{})

Set 设置配置项目

func Setup

func Setup(option ConfigOption) error

Types

type ConfigOption

type ConfigOption struct {
	Type      string
	File      string
	Name      string
	Paths     []string
	EnvPrefix string
}

type StrMap

type StrMap map[string]interface{}

StrMap 简写 —— map[string]interface{}

Jump to

Keyboard shortcuts

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