func main() {
type User struct {
Id int
Name string `params:"name"`
Pass string `my-tag1:"pass1" my-tag2:"pass2" params:"pass"`
}
var user *User
fields, _ := gstructs.Fields(gstructs.FieldsInput{
Pointer: user,
RecursiveOption: 0,
})
g.Dump(fields)
}
// Output:
[
{
Value: "<int Value>",
Field: {
Name: "Id",
PkgPath: "",
Type: "int",
Tag: "",
Offset: 0,
Index: [
0,
],
Anonymous: false,
},
TagValue: "",
},
{
Value: {},
Field: {
Name: "Name",
PkgPath: "",
Type: "string",
Tag: "params:\"name\"",
Offset: 8,
Index: [
1,
],
Anonymous: false,
},
TagValue: "",
},
{
Value: {},
Field: {
Name: "Pass",
PkgPath: "",
Type: "string",
Tag: "my-tag1:\"pass1\" my-tag2:\"pass2\" params:\"pass\"",
Offset: 24,
Index: [
2,
],
Anonymous: false,
},
TagValue: "",
},
]