dchook

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dchook holds the reflection logic shared by poya's mapstructure decode hooks. It deliberately imports no mapstructure package so the same code backs both the mitchellh/mapstructure hooks (package hooks) and the go-viper/mapstructure/v2 hooks (package mapstructurev2). The exported functions all use the (from, to reflect.Value) (any, error) shape that both mapstructure forks accept as a DecodeHookFuncValue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hook

func Hook(from, to reflect.Value) (any, error)

Hook implements the general decode hook: it detects a target *poya.DcValue[T] and initializes it from the source, handling scalar, time.Duration, time.Time, struct, and slice kinds. Non-matching values pass through unchanged.

func JSONString

func JSONString(from, to reflect.Value) (any, error)

JSONString decodes a JSON string source (a struct or array stored as a single config value) into a struct or slice DcValue[T]. Non-matching values pass through unchanged.

func StringToDcValue

func StringToDcValue(from, to reflect.Value) (any, error)

StringToDcValue handles only string sources targeting a DcValue[T] with a non-string scalar T (int, uint, float, bool, complex, time.Duration, time.Time, or any encoding.TextUnmarshaler). Non-matching values pass through unchanged so it can be composed with other hooks.

Types

This section is empty.

Jump to

Keyboard shortcuts

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