Documentation ¶
Overview ¶
Package structs provides functions for struct conversion.
Inspired and improved from: https://github.com/fatih/structs
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MapField ¶
MapField retrieves struct field as map[name/tag]*Field from <pointer>, and returns the map.
The parameter <pointer> should be type of struct/*struct.
The parameter <priority> specifies the priority tag array for retrieving from high to low.
Note that it only retrieves the exported attributes with first letter up-case from struct.
func TagMapField ¶
TagMapField retrieves struct tags as map[tag]*Field from <pointer>, and returns it.
The parameter <pointer> should be type of struct/*struct.
Note that it only retrieves the exported attributes with first letter up-case from struct.
func TagMapName ¶
TagMapName retrieves struct tags as map[tag]attribute from <pointer>, and returns it.
The parameter <pointer> should be type of struct/*struct.
Note that it only retrieves the exported attributes with first letter up-case from struct.
Types ¶
type Field ¶
type Field struct { // Retrieved tag value. There might be more than one tags in the field, // but only one can be retrieved according to calling function rules. TagValue string // contains filtered or unexported fields }
Field contains information of a struct field .
func TagFields ¶ added in v1.10.1
TagFields retrieves struct tags as []*Field from <pointer>, and returns it.
The parameter <pointer> should be type of struct/*struct.
Note that it only retrieves the exported attributes with first letter up-case from struct.
func (*Field) IsEmbedded ¶ added in v1.14.3
IsEmbedded returns true if the given field is an anonymous field (embedded)
func (*Field) IsExported ¶ added in v1.14.3
IsExported returns true if the given field is exported.