config

package
v0.2.10-17 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CfgDir   string
	CfgPath  string
	Replacer = strings.NewReplacer(".", "_", "-", "_", "/", "_")
)

Functions

func Load

func Load[T any]() T

func Merge

func Merge[A any, B any](dst A, src *B) *A

Types

type Config

type Config interface {
	UnmarshalKey(key string, rawVal interface{}, opts ...DecoderOption) error
	Unmarshal(rawVal interface{}, opts ...DecoderOption) error

	// DecodeComponent decode component config to map[string]*struct
	DecodeComponent(name string, cfgMap interface{}) error
	Get(key string) interface{}
	Set(string, interface{})
	GetString(key string) string
	AllKeys() []string
	All() map[string]interface{}
}

func New

func New() Config

New 处理所有的配置,环境变量和flag 配置顺序, 默认值->环境变量->配置文件->flag 配置文件中可以设置环境变量 flag可以指定配置文件位置 始化配置文件

type DecoderOption

type DecoderOption = viper.DecoderConfigOption

type Map

type Map map[string]any

func (Map) Decode

func (c Map) Decode(val any, tags ...string) error

Jump to

Keyboard shortcuts

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