Skip to content

Commit

Permalink
added template with fields in map && added it to basic templates
Browse files Browse the repository at this point in the history
  • Loading branch information
abramlab committed Aug 26, 2021
1 parent 3e3e28d commit 91a9148
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tpls.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
structNameTpl,
structFieldsTpl,
structFieldsArrayTpl,
structFieldsMapTpl,
},
}
genjiTemplates = &Template{
Expand Down Expand Up @@ -56,6 +57,13 @@ var (
{{$.Name}}Fields.{{$field.Name}},
{{end}}
}
`))
structFieldsMapTpl = template.Must(template.New("structFieldsMapTpl").Parse(
`var {{.Name}}FieldsMap = map[string]struct{}{
{{range $field := .Fields -}}
"{{ .Value }}": {},
{{end}}
}
`))
)

Expand Down

0 comments on commit 91a9148

Please sign in to comment.