configdecode

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 4 Imported by: 0

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.

Jump to

Keyboard shortcuts

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