Documentation
¶
Index ¶
- func CompareValues(v1, v2 reflect.Value, op string, ignoreCase bool) (bool, error)
- func ConvertValue(v reflect.Value, targetType reflect.Type) reflect.Value
- func Copy[T any](src T, opts ...CopyOption) (T, error)
- func DeepCopyValue(v reflect.Value) reflect.Value
- func Dereference(v reflect.Value) (reflect.Value, error)
- func Equal[T any](a, b T, opts ...EqualOption) bool
- func EscapeKey(key string) string
- func ExtractKey(v reflect.Value, fieldIdx int) any
- func GetKeyField(typ reflect.Type) (int, bool)
- func InterfaceToValue(i any) reflect.Value
- func JoinPath(parent, child string) string
- func MustCopy[T any](src T, opts ...CopyOption) T
- func NormalizePath(path string) string
- func RegisterCustomCopy(typ reflect.Type, fn reflect.Value)
- func RegisterCustomEqual(typ reflect.Type, fn reflect.Value)
- func SetValue(v, newVal reflect.Value)
- func ToReflectValue(v any) reflect.Value
- func ValueEqual(a, b reflect.Value, config *equalConfig) bool
- func ValueToInterface(v reflect.Value) any
- type Copier
- type CopyOption
- type DeepPath
- func (p DeepPath) Delete(v reflect.Value) error
- func (p DeepPath) Navigate(v reflect.Value, parts []PathPart) (reflect.Value, PathPart, error)
- func (p DeepPath) Resolve(v reflect.Value) (reflect.Value, error)
- func (p DeepPath) ResolveParent(v reflect.Value) (reflect.Value, PathPart, error)
- func (p DeepPath) ResolveParentPath() (DeepPath, PathPart, error)
- func (p DeepPath) Set(v reflect.Value, val reflect.Value) error
- func (p DeepPath) StripParts(prefix []PathPart) DeepPath
- type EqualOption
- type FieldInfo
- type PathPart
- type StructTag
- type TypeInfo
- type VisitKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareValues ¶
func Copy ¶
func Copy[T any](src T, opts ...CopyOption) (T, error)
Copy creates a deep copy of src. It returns the copy and a nil error in case of success and the zero value for the type and a non-nil error on failure.
It correctly handles cyclic references and unexported fields.
func Equal ¶
func Equal[T any](a, b T, opts ...EqualOption) bool
Equal performs a deep equality check between a and b.
func InterfaceToValue ¶
func MustCopy ¶
func MustCopy[T any](src T, opts ...CopyOption) T
MustCopy creates a deep copy of src. It returns the copy on success or panics in case of any failure.
It correctly handles cyclic references and unexported fields.
func NormalizePath ¶
NormalizePath converts a dot-notation or JSON Pointer path to a standard JSON Pointer.
func RegisterCustomCopy ¶
RegisterCustomCopy registers a custom copy function for a specific type. The function must be of type func(src T) (T, error).
func RegisterCustomEqual ¶
RegisterCustomEqual registers a custom equality function for a specific type. The function must be of type func(a, b T) bool.
func ToReflectValue ¶
func ValueEqual ¶
ValueEqual performs a deep equality check between two reflect.Values.
func ValueToInterface ¶
Types ¶
type Copier ¶
Copier is an interface that types can implement to provide their own custom deep copy logic. The type T in Copy() (T, error) must be the same concrete type as the receiver that implements this interface.
type CopyOption ¶
type CopyOption interface {
// contains filtered or unexported methods
}
CopyOption allows configuring the behavior of the Copy function.
func CopyIgnorePath ¶
func CopyIgnorePath(path string) CopyOption
CopyIgnorePath returns an option that tells Copy to ignore the specified path. The ignored path will have the zero value for its type in the resulting copy.
func SkipUnsupported ¶
func SkipUnsupported() CopyOption
SkipUnsupported returns an option that tells Copy to skip unsupported types (like non-nil functions or channels) instead of returning an error.
type DeepPath ¶
type DeepPath string
DeepPath represents a path to a field or element within a structure. It supports JSON Pointers (RFC 6901) syntax like "/Field/SubField".
func (DeepPath) ResolveParent ¶
func (DeepPath) ResolveParentPath ¶
ResolveParentPath splits the path into parent path and the last part.
func (DeepPath) StripParts ¶
type EqualOption ¶
type EqualOption interface {
// contains filtered or unexported methods
}
EqualOption allows configuring the behavior of the Equal function.
func EqualIgnorePath ¶
func EqualIgnorePath(path string) EqualOption
EqualIgnorePath returns an option that tells Equal to ignore the specified path.