Documentation
¶
Index ¶
- type Extractor
- func (e *Extractor) FieldValueFromTagMap(tag string) (out map[string]interface{}, err error)
- func (e *Extractor) FieldValueMap() (out map[string]interface{}, err error)
- func (e *Extractor) IgnoreField(fd ...string) *Extractor
- func (e *Extractor) Names() (out []string, err error)
- func (e *Extractor) NamesFromTag(tag string) (out []string, err error)
- func (e *Extractor) NamesFromTagWithPrefix(tag string, prefix string) (out []string, err error)
- func (e *Extractor) TagMapping(from, to string) (out map[string]string, err error)
- func (e *Extractor) UseEmbeddedStructs(use bool) *Extractor
- func (e *Extractor) Values() (out []interface{}, err error)
- func (e *Extractor) ValuesFromTag(tag string) (out []interface{}, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Extractor ¶
type Extractor struct {
StructAddr interface{} // StructAddr: struct address
// contains filtered or unexported fields
}
Extractor holds the struct that we want to extract data from
func New ¶
func New(s interface{}) *Extractor
New returns a new Extractor struct the parameter have to be a pointer to a struct
func (*Extractor) FieldValueFromTagMap ¶
FieldValueFromTagMap returns a string to interface map that uses as key the tag name, key: tag name for the given field value: the value of the field omitempty tag option will ignore empty fields
func (*Extractor) FieldValueMap ¶
FieldValueMap returns a string to interface map, key: field as defined on the struct value: the value of the field
func (*Extractor) IgnoreField ¶
IgnoreField checks if the given fields are valid based on the given struct, then append them on the ignore list e.g. ext := structextract.New(&business).IgnoreField("ID","DateModified")
func (*Extractor) Names ¶
Names returns an array with all the field names (with the same order) as defined on the struct
func (*Extractor) NamesFromTag ¶
NamesFromTag returns an array with all the tag names for each field omitempty tag option will ignore empty fields
func (*Extractor) NamesFromTagWithPrefix ¶
NamesFromTagWithPrefix returns an array with all the tag names for each field including the given prefix omitempty tag option will ignore empty fields
func (*Extractor) TagMapping ¶
TagMapping returns a map that maps tagged fields from one tag to another. This can help with mapping partial JSON objects to some other kind of a mapping, such as SQL. It only maps existing field pairs, if either field does not have a tag, it's left out.
func (*Extractor) UseEmbeddedStructs ¶
UseEmbeddedStructs toggles the usage of embedded structs
func (*Extractor) ValuesFromTag ¶
ValuesFromTag returns an interface array with all the values of fields with the given tag omitempty tag option will ignore empty fields