package
3.6.3+incompatible
Repository: https://github.com/frazercomputing/upper-io-db.git
Documentation: pkg.go.dev

# README

reflectx

The sqlx package has special reflect needs. In particular, it needs to:

  • be able to map a name to a field
  • understand embedded structs
  • understand mapping names to fields by a particular tag
  • user specified name -> field mapping functions

These behaviors mimic the behaviors by the standard library marshallers and also the behavior of standard Go accessors.

The first two are amply taken care of by Reflect.Value.FieldByName, and the third is addressed by Reflect.Value.FieldByNameFunc, but these don't quite understand struct tags in the ways that are vital to most marshalers, and they are slow.

This reflectx package extends reflect to achieve these goals.

# Functions

Deref is Indirect for reflect.Types.
FieldByIndexes returns a value for a particular struct traversal.
FieldByIndexesReadOnly returns a value for a particular struct traversal, but is not concerned with allocating nil pointers because the value is going to be used for reading and not setting.
NewMapper returns a new mapper which optionally obeys the field tag given by tagName.
NewMapperFunc returns a new mapper which optionally obeys a field tag and a struct field name mapper func given by f.
NewMapperTagFunc returns a new mapper which contains a mapper for field names AND a mapper for tag values.
ValidFieldByIndexes returns a value for a particular struct traversal.

# Structs

A FieldInfo is a collection of metadata about a struct field.
Mapper is a general purpose mapper of names to struct fields.
A StructMap is an index of field metadata for a struct.