Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToAnyType ¶
func ToAnyType[T any](input interface{}) *T
ToAnyType attempts to convert an input of any type to the specified type T. It returns a pointer to the converted value if successful, or nil if the conversion fails.
Parameters:
- input: An interface{} representing the value to be converted.
Returns:
- A pointer to the converted value of type T, or nil if the conversion fails.
Example:
var input interface{} = 123
result := ToAnyType[int](input)
if result != nil {
fmt.Println(*result) // Output: 123
} else {
fmt.Println("Conversion failed")
}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.