Documentation
¶
Index ¶
- Variables
- func HookFuncDefault() mapstructure.DecodeHookFuncType
- func HookFuncEnvRender() mapstructure.DecodeHookFuncType
- func HookFuncStringToBool() mapstructure.DecodeHookFuncType
- func HookFuncStringToSlice() mapstructure.DecodeHookFuncType
- func HookFuncStringToSlogLevel() mapstructure.DecodeHookFuncType
- func Load[T any](obj *T, uris ...string) error
- func LoadCtx[T any](ctx context.Context, obj *T, uris ...string) error
- type ConfEvent
- type ConfOpt
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultParserConfig = mapstructure.DecoderConfig{ DecodeHook: mapstructure.ComposeDecodeHookFunc( HookFuncDefault(), HookFuncEnvRender(), HookFuncStringToSlice(), HookFuncStringToBool(), HookFuncStringToSlogLevel(), mapstructure.StringToTimeDurationHookFunc(), mapstructure.StringToSliceHookFunc(","), mapstructure.StringToBasicTypeHookFunc(), ), TagName: "json", WeaklyTypedInput: true, ErrorUnused: false, ZeroFields: false, MatchName: func(mapKey, fieldName string) bool { return strings.EqualFold(strings.ReplaceAll(mapKey, "_", ""), fieldName) }, }
DefaultParserConfig 默认解析器配置
Functions ¶
func HookFuncDefault ¶
func HookFuncDefault() mapstructure.DecodeHookFuncType
HookFuncDefault 默认值钩子,当其他钩子都无法处理时提供默认值
func HookFuncEnvRender ¶
func HookFuncEnvRender() mapstructure.DecodeHookFuncType
HookFuncEnvRender 环境变量渲染钩子
func HookFuncStringToBool ¶
func HookFuncStringToBool() mapstructure.DecodeHookFuncType
HookFuncStringToBool 字符串和数字到布尔值的钩子
func HookFuncStringToSlice ¶ added in v0.5.2
func HookFuncStringToSlice() mapstructure.DecodeHookFuncType
HookFuncStringToSlice supports structured slice literals such as JSON/YAML flow sequences while preserving the existing CSV fallback hook behavior.
func HookFuncStringToSlogLevel ¶
func HookFuncStringToSlogLevel() mapstructure.DecodeHookFuncType
HookFuncStringToSlogLevel 字符串和数字到slog.Level的钩子
Types ¶
type ConfEvent ¶
type ConfOpt ¶
type ConfOpt[T any] struct { ParserConf mapstructure.DecoderConfig // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.