config

package
v0.2.10-37 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CfgDir  string
	CfgPath string
)

Functions

func Load

func Load[T any]() T

func Merge

func Merge[A any, B any](to A, from *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