Skip to content

Commit 91a9148

Browse files
committed
added template with fields in map && added it to basic templates
1 parent 3e3e28d commit 91a9148

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tpls.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var (
2121
structNameTpl,
2222
structFieldsTpl,
2323
structFieldsArrayTpl,
24+
structFieldsMapTpl,
2425
},
2526
}
2627
genjiTemplates = &Template{
@@ -56,6 +57,13 @@ var (
5657
{{$.Name}}Fields.{{$field.Name}},
5758
{{end}}
5859
}
60+
`))
61+
structFieldsMapTpl = template.Must(template.New("structFieldsMapTpl").Parse(
62+
`var {{.Name}}FieldsMap = map[string]struct{}{
63+
{{range $field := .Fields -}}
64+
"{{ .Value }}": {},
65+
{{end}}
66+
}
5967
`))
6068
)
6169

0 commit comments

Comments
 (0)