Reflect
The Reflect registry offers tools for inspecting and manipulating data types using reflection, enabling advanced dynamic type handling within your projects.
typeIs
The function compares the type of the provided value (src
) to a specified target type string (target
). It returns true
if the type of src
matches the target type.
Signature
typeIsLike
The function compares the type of the provided value (src
) to a target type string (target
), with an option for a wildcard *
prefix (pointer). It returns true
if src
matches target
or *target
, which is useful for checking if a variable is of a specific type or a pointer to that type.
Signature
typeOf
The function returns the type of the provided value (src
) as a string, giving you a textual representation of its data type.
Signature
kindIs
The function compares the kind (category) of a given value (src
) to a target kind string (target
). It returns true
if the kind of src
matches the specified target kind.
Signature
kindOf
The function returns the kind (category) of the provided value (src
) as a string, giving a general classification like "int," "struct," or "slice."
Signature
hasField
The function checks the presence of a field with the specified name (name
) in the provided struct (src
). It returns true
if the field exists.
Signature
Assuming Struct has defined as : type Struct struct { V string }
deepEqual
The function checks if two variables, x
and y
, are deeply equal by comparing their values and structures using reflect.DeepEqual
.
Signature
deepCopy
Signature
Last updated