Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
Get returns a map of Field objects. It takes a parameter `T` of type `any`, representing the type to be used for Fields map creation.
func GetFrom ¶
GetFrom returns a map of Field objects. It takes a parameter `obj` of type `interface{}` representing the object to be analyzed. The function first checks if the `obj` type is already in the cache, and if it exists, it returns the cached value. Otherwise, it creates a new empty map with fields.
Types ¶
type Field ¶
type Field reflect.StructField
func (Field) Get ¶
func (f Field) Get(obj interface{}) interface{}
Get returns the value of the fields in the provided object. It takes a parameter `obj` of type `interface{}`, representing the object. It returns the value of the fields as an `interface{}`.
func (Field) Set ¶
func (f Field) Set(obj interface{}, val interface{})
Set updates the value of the fields in the provided object with the provided value. It takes two parameters:
- obj: interface{}, representing the object containing the field.
- val: interface{}, representing the new value for the field.
The Set method uses the getPtr method to get a pointer to the fields in the object. It then performs a type switch on the kind of the fields to determine its type, and sets the value accordingly. The supported fields types are string, int, and bool. If the fields type is not one of the supported types, it panics with the message "unhandled default case".