hooks

package
v0.1.72 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvSubst

func EnvSubst() mapstructure.DecodeHookFunc

EnvSubst applies bash env substitution on the given input.

func GetExtraHooks

func GetExtraHooks() []mapstructure.DecodeHookFunc

func IntToNetAddrPortHook added in v0.1.59

func IntToNetAddrPortHook() mapstructure.DecodeHookFunc

IntToNetAddrPortHook produces a mapstructure.DecodeHookFunc that converts signed integer values into netip.AddrPort values. IntToNetAddrPortHook returns a mapstructure.DecodeHookFunc that converts signed integers into netip.AddrPort values. The hook treats the integer as a port on "127.0.0.1", parses "127.0.0.1:<port>" into a netip.AddrPort, and returns a parsing error if the port is invalid.

func LooseTypeCaster

func LooseTypeCaster() mapstructure.DecodeHookFunc

func RegisterHook

func RegisterHook(hook mapstructure.DecodeHookFunc)

func StringToCIDRHook added in v0.1.59

func StringToCIDRHook() mapstructure.DecodeHookFunc

StringToCIDRHook provides a mapstructure.DecodeHookFunc that parses CIDR-formatted strings into net.IP values.

Empty string inputs produce a nil result. For valid CIDR strings the hook returns the IP component from net.ParseCIDR. Invalid CIDR strings return the parsing error. Non-string source values are returned unchanged.

func StringToNetAddrHook added in v0.1.59

func StringToNetAddrHook() mapstructure.DecodeHookFunc

StringToNetAddrHook returns a mapstructure.DecodeHookFunc that converts string inputs into net.IP values.

The returned hook only acts when the source kind is string and the target type is net.IP. For an empty string it yields nil; for a non-empty string it parses the value with net.ParseIP and returns the resulting net.IP or an error if parsing fails. If the incoming value is not a string, the hook returns an error stating a string was expected. For non-matching source/target types the hook returns the input unchanged.

func StringToNetAddrPortHook added in v0.1.59

func StringToNetAddrPortHook() mapstructure.DecodeHookFunc

StringToNetAddrPortHook returns a mapstructure.DecodeHookFunc that converts string values into netip.AddrPort.

The hook accepts either "host:port" or "port". If only a port is provided, the host defaults to "127.0.0.1". An empty string yields the zero netip.AddrPort. If the input is not a string, the hook returns an error; if the string cannot be parsed as an address:port, the hook returns the parsing error.

func StringToSliceHookFunc

func StringToSliceHookFunc(sep string) mapstructure.DecodeHookFunc

stringToSliceHookFunc converts strings to slices.

Types

This section is empty.

Jump to

Keyboard shortcuts

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