2025-06-04 22:01:47 +08:00
|
|
|
// Package mapstruct provides bidirectional conversion between Go structs and maps.
|
|
|
|
// It supports:
|
|
|
|
// - Struct <-> map[string]any
|
|
|
|
// - Struct <-> map[string]string
|
|
|
|
// - Custom type conversion via hooks
|
|
|
|
// - Nested structs and pointers
|
|
|
|
// - Field name mapping via struct tags
|
|
|
|
package mapstruct
|
|
|
|
|
2025-06-04 22:59:12 +08:00
|
|
|
//import (
|
|
|
|
// "reflect"
|
2025-06-04 22:01:47 +08:00
|
|
|
//)
|
2025-06-04 22:59:12 +08:00
|
|
|
//
|
|
|
|
//// HookFunc defines a function type for custom field conversion.
|
|
|
|
//type HookFunc func(reflect.Value, reflect.StructField) (any, error)
|
|
|
|
//
|
|
|
|
//// StringHookFunc defines a function type for custom string-to-value conversion.
|
|
|
|
//type StringHookFunc func(string, reflect.StructField) (any, error)
|
|
|
|
//
|
|
|
|
//// Direction indicates the conversion direction.
|
|
|
|
////type Direction int
|
|
|
|
////
|
|
|
|
////const (
|
|
|
|
//// StructToMap Direction = iota
|
|
|
|
//// MapToStruct
|
|
|
|
////)
|
|
|
|
//
|
|
|
|
//// commonOptions contains options shared by both conversions.
|
|
|
|
//type commonOptions struct {
|
|
|
|
// TagName string
|
|
|
|
// FieldHooks map[string]HookFunc
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//// newCommonOptions creates a new commonOptions with defaults.
|
|
|
|
//func newCommonOptions() *commonOptions {
|
|
|
|
// return &commonOptions{
|
|
|
|
// TagName: "json",
|
|
|
|
// }
|
|
|
|
//}
|