Documentation
¶
Overview ¶
Package configdecode holds mapstructure decode hooks shared by the go-bricks config and migration packages, so the numeric-duration guard has a single source of truth inside the module. The tools/migration CLI is a separate module and cannot import go-bricks/internal, so it keeps a byte-identical local copy in sync with this one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NumericToDurationGuardHookFunc ¶
func NumericToDurationGuardHookFunc() mapstructure.DecodeHookFunc
NumericToDurationGuardHookFunc rejects a bare numeric bound to a time.Duration field: WeaklyTypedInput would otherwise coerce it to that many raw nanoseconds (300 -> 300ns), booting a broken config. Edge cases: an explicit zero (int/uint/float, incl. -0.0) is the framework-wide "unset -> use default" idiom and passes; a bool is never a duration and is always rejected; a source that is already time.Duration (e.g. a typed default) passes. Guards exact time.Duration only, matching StringToTimeDurationHookFunc's scope.
Mirrored in tools/migration/internal/commands/common.go (a separate module that cannot import go-bricks/internal) — keep the two in sync.
Types ¶
This section is empty.