config

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CfgType   = "yaml"
	CfgName   = "config"
	CfgDir    = env.Get("app_cfg_home", "project_cfg_home", consts.EnvCfgHome)
	CfgPath   = filepath.Join("configs", "config", "config.yaml")
	EnvPrefix = utils.FirstNotEmpty(env.Get("cfg_env_prefix", "app_env_prefix", "project_env_prefix", consts.EnvCfgPrefix), "lava")
)

Functions

func Decode

func Decode[Cfg any](c Config, name string) map[string]Cfg

func MakeClient added in v0.2.4

func MakeClient[Cfg any, Client any](c Config, name string, callback func(key string, cfg Cfg) Client) map[string]Client

Types

type App added in v0.2.2

type App struct {
	Debug     bool   `yaml:"debug"`
	Addr      string `yaml:"addr"`
	Advertise string `yaml:"advertise"`
}

func (*App) Check added in v0.2.2

func (c *App) Check() (err error)

type CfgMap added in v0.1.26

type CfgMap map[string]interface{}

func (CfgMap) Decode added in v0.1.26

func (t CfgMap) Decode(val interface{}) error

func (CfgMap) GetString added in v0.2.3

func (t CfgMap) GetString(name string) string

type Config

type Config interface {
	LoadPath(path string)
	UnmarshalKey(key string, rawVal interface{}, opts ...DecoderOption) error
	Decode(name string, cfgMap interface{}) error
	Get(key string) interface{}
	Set(string, interface{})
	GetString(key string) string
	GetMap(keys ...string) CfgMap
	AllKeys() []string
	MergeConfig(in io.Reader) error
	All() map[string]interface{}
}

type DecoderOption added in v0.2.4

type DecoderOption = viper.DecoderConfigOption

Jump to

Keyboard shortcuts

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