Documentation
¶
Overview ¶
Package value provides utilities for type casting and copying values using reflection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cast ¶
Cast performs a type assertion to convert an interface{} value to a specific type T. Returns the zero value of type T if the conversion fails. This is a generic function that provides safe type casting.
func Copy ¶
func Copy(from interface{}, to interface{})
Copy performs a deep copy of values from the source to the destination using reflection. It handles primitive types, structs, and maps with type compatibility checking. Both from and to parameters can be pointers or values. The function only copies fields with matching names and compatible types. Optimized version with reduced reflection overhead and early type checking.
func JsonMarshal ¶
func JsonMarshal(obj interface{}) string
JsonMarshal converts an object to its JSON string representation. Returns an empty string if the marshaling fails. This provides a safe way to convert objects to JSON without handling errors explicitly. Optimized version with early type checking and reduced allocations.
Types ¶
This section is empty.