The reflections
package provides functionality for working with reflection in Go.
To use this package, import it in your Go code:
import "github.com/getevo/evo/v2/lib/reflections"
func GetField(obj interface{}, name string) (interface{}, error)
Description: Returns the value of the provided object field.
func GetFieldKind(obj interface{}, name string) (reflect.Kind, error)
Description: Returns the kind of the provided object field.
func GetFieldType(obj interface{}, name string) (string, error)
Description: Returns the type of the provided object field.
func GetFieldTag(obj interface{}, fieldName, tagKey string) (string, error)
Description: Returns the tag value of the provided object field.
func GetFieldNameByTagValue(obj interface{}, tagKey, tagValue string) (string, error)
Description: Looks up a field with a matching tag value in the provided object.
func SetField(obj interface{}, name string, value interface{}) error
Description: Sets the value of the provided object field.
func HasField(obj interface{}, name string) (bool, error)
Description: Checks if the provided object has a field with the given name.
func Fields(obj interface{}) ([]string, error)
Description: Returns the names of the fields in the provided object.
func FieldsDeep(obj interface{}) ([]string, error)
Description: Returns the "flattened" names of the fields in the provided object, including fields from anonymous inner structs.
func Items(obj interface{}) (map[string]interface{}, error)
Description: Returns the field:value pairs of the provided object as a map.
func ItemsDeep(obj interface{}) (map[string]interface{}, error)
Description: Returns the "flattened" field:value pairs of the provided object as a map, including fields from anonymous inner structs.
func Tags(obj interface{}, key string) (map[string]string, error)
Description: Returns the tags of the fields in the provided object as a map.
func TagsDeep(obj interface{}, key string) (map[string]string, error)
Description: Returns the "flattened" tags of the fields in the provided object as a map, including fields from anonymous inner structs.