Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ValueEntry ¶
type ValueEntry struct { reflect.Value Parent reflect.Value // Key is current Value's key in Parent map. Key reflect.Value // Idx is current Value's idx in Parent struct fields or Parent array/slice Idx int }
func ValueEntryByPath ¶
func ValueEntryByPath(value any, path string) (*ValueEntry, error)
func (ValueEntry) StructField ¶
func (e ValueEntry) StructField() (reflect.StructField, bool)
StructField returns current reflect.StructField in Parent struct.
type ValueOptions ¶
type ValueOptions struct {
IgnorePtr bool
}
func (ValueOptions) GetValue ¶
func (o ValueOptions) GetValue(value any, path string) (any, error)
GetValue get value by ValueEntryByPath. Note: you can't get un-exported field.
func (ValueOptions) SetValue ¶
func (o ValueOptions) SetValue(value any, path string, v any) error
SetValue set value by ValueEntryByPath. Note: you can't set un-exported field and that the field and value types must match.
func (ValueOptions) ValueEntryByPath ¶
func (o ValueOptions) ValueEntryByPath(value any, path string) (*ValueEntry, error)
ValueEntryByPath access a field of value by a path. The path is represented by Go's expression which can be parsed by go/parser.ParseExpr. But the extra feature is, you can use "$" to represent the value root path. You can use selectors and indexes in a path. Slice and arrays index allow only expressions of int. Maps key allow expressions of int, float, complex, char and string.