cfg

package
v0.0.0-...-df2ac98 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ErrCodeCfgMissing = "CFG_MISSING"
	ErrCodeCfgBadType = "CFG_BAD_TYPE"
)

Variables

This section is empty.

Functions

func GetBool

func GetBool(c Cfg, key string, def ...bool) (bool, error)

func GetBoolDef

func GetBoolDef(key string, def ...bool) (bool, error)

func GetFloat

func GetFloat[T types.FloatUnion](c Cfg, key string, def ...T) (T, error)

func GetFloatDef

func GetFloatDef[T types.FloatUnion](key string, def ...T) (T, error)

func GetInt

func GetInt[T types.IntUnion](c Cfg, key string, def ...T) (T, error)

func GetIntDef

func GetIntDef[T types.IntUnion](key string, def ...T) (T, error)

func GetObj

func GetObj[T any](c Cfg, key string, def ...T) (T, error)

func GetObjDef

func GetObjDef[T any](key string, def ...T) (T, error)

func GetStr

func GetStr(c Cfg, key string, def ...string) (string, error)

func GetStrDef

func GetStrDef(key string, def ...string) (string, error)

func GetUint

func GetUint[T types.UintUnion](c Cfg, key string, def ...T) (T, error)

func GetUintDef

func GetUintDef[T types.UintUnion](key string, def ...T) (T, error)

func HasDefault

func HasDefault() bool

func SetDefault

func SetDefault(cfg Cfg)

Types

type Cfg

type Cfg map[string]any

func ParseJsonDir

func ParseJsonDir(jsonDir string) (Cfg, error)

func ParseJsonFile

func ParseJsonFile(jsonPath string) (Cfg, error)

func ParseJsonString

func ParseJsonString(jsonStr string) (Cfg, error)

func SetDefaultFromDir

func SetDefaultFromDir(jsonDir string) (Cfg, error)

func SetDefaultFromFile

func SetDefaultFromFile(jsonPath string) (Cfg, error)

func SetDefaultFromStr

func SetDefaultFromStr(jsonStr string) (Cfg, error)

func (Cfg) GetBool

func (c Cfg) GetBool(key string, def ...bool) (bool, error)

func (Cfg) GetFloat32

func (c Cfg) GetFloat32(key string, def ...float32) (float32, error)

func (Cfg) GetFloat64

func (c Cfg) GetFloat64(key string, def ...float64) (float64, error)

func (Cfg) GetInt

func (c Cfg) GetInt(key string, def ...int) (int, error)

func (Cfg) GetInt16

func (c Cfg) GetInt16(key string, def ...int16) (int16, error)

func (Cfg) GetInt32

func (c Cfg) GetInt32(key string, def ...int32) (int32, error)

func (Cfg) GetInt64

func (c Cfg) GetInt64(key string, def ...int64) (int64, error)

func (Cfg) GetInt8

func (c Cfg) GetInt8(key string, def ...int8) (int8, error)

func (Cfg) GetMap

func (c Cfg) GetMap(key string, def ...map[string]any) (map[string]any, error)

func (Cfg) GetObj

func (c Cfg) GetObj(key string, t *any, def ...any) error

func (Cfg) GetStr

func (c Cfg) GetStr(key string, def ...string) (string, error)

func (Cfg) GetUint

func (c Cfg) GetUint(key string, def ...uint) (uint, error)

func (Cfg) GetUint16

func (c Cfg) GetUint16(key string, def ...uint16) (uint16, error)

func (Cfg) GetUint32

func (c Cfg) GetUint32(key string, def ...uint32) (uint32, error)

func (Cfg) GetUint64

func (c Cfg) GetUint64(key string, def ...uint64) (uint64, error)

func (Cfg) GetUint8

func (c Cfg) GetUint8(key string, def ...uint8) (uint8, error)

func (Cfg) Merge

func (c Cfg) Merge(another Cfg) Cfg

Jump to

Keyboard shortcuts

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