@@ -24,6 +24,7 @@ func init() {
2424 "quickfixType" : quickfixType ,
2525 "quickfixValueType" : quickfixValueType ,
2626 "getGlobalFieldType" : getGlobalFieldType ,
27+ "collectStandardImports" : collectStandardImports ,
2728 "collectExtraImports" : collectExtraImports ,
2829 "checkIfDecimalImportRequiredForFields" : checkIfDecimalImportRequiredForFields ,
2930 "checkIfTimeImportRequiredForFields" : checkIfTimeImportRequiredForFields ,
@@ -112,7 +113,14 @@ func ({{ template "receiver" }} {{ $.Name }}) Has{{ .Name}}() bool {
112113
113114{{ define "group_template" }}
114115quickfix.GroupTemplate{
115- {{- range $index, $field := . }}{{if $index}},{{end}}{{if $field.IsGroup }}New{{ $field.Name }}RepeatingGroup(){{else}}quickfix.GroupElement(tag.{{$field.Name}}){{ end }}{{ end }} }
116+ {{- range $index, $field := . }}
117+ {{- if $field.IsGroup }}
118+ New{{ $field.Name }}RepeatingGroup(),
119+ {{- else}}
120+ quickfix.GroupElement(tag.{{$field.Name}}),
121+ {{- end }}
122+ {{- end }}
123+ }
116124{{- end }}
117125
118126{{ define "field_args" }}
@@ -140,7 +148,11 @@ type {{ .Name }}RepeatingGroup struct {
140148// New{{ .Name }}RepeatingGroup returns an initialized, {{ .Name }}RepeatingGroup.
141149func New{{ .Name }}RepeatingGroup() {{ .Name }}RepeatingGroup {
142150 return {{ .Name }}RepeatingGroup{
143- quickfix.NewRepeatingGroup(tag.{{ .Name }}, {{ template "group_template" .Fields }})}
151+ quickfix.NewRepeatingGroup(
152+ tag.{{ .Name }},
153+ {{- template "group_template" .Fields }},
154+ ),
155+ }
144156}
145157
146158// Add create and append a new {{ .Name }} to this group.
@@ -161,12 +173,17 @@ func ({{ template "receiver" }} {{ .Name}}RepeatingGroup) Get(i int) {{ .Name }}
161173{{ define "receiver" }}h{{ end }}
162174package {{ .Package }}
163175
164- import(
176+ import (
177+ {{- if collectStandardImports .MessageDef }}
178+ {{- range collectStandardImports .MessageDef }}
179+ "{{ . }}"
180+ {{- end }}{{ "\n" }}
181+ {{- end }}
182+ {{- if collectExtraImports .MessageDef }}
165183 {{- range collectExtraImports .MessageDef }}
166184 "{{ . }}"
185+ {{- end }}{{ "\n" }}
167186 {{- end }}
168-
169-
170187 "github.com/quickfixgo/quickfix"
171188 {{- if checkIfEnumImportRequired .MessageDef}}
172189 "{{ importRootPath }}/enum"
@@ -197,11 +214,17 @@ func NewHeader(header *quickfix.Header) (h Header) {
197214{{ define "receiver" }}t{{ end }}
198215package {{ .Package }}
199216
200- import(
217+ import (
218+ {{- if collectStandardImports .MessageDef }}
219+ {{- range collectStandardImports .MessageDef }}
220+ "{{ . }}"
221+ {{- end }}{{ "\n" }}
222+ {{- end }}
223+ {{- if collectExtraImports .MessageDef }}
201224 {{- range collectExtraImports .MessageDef }}
202225 "{{ . }}"
226+ {{- end }}{{ "\n" }}
203227 {{- end }}
204-
205228 "github.com/quickfixgo/quickfix"
206229 {{- if checkIfEnumImportRequired .MessageDef}}
207230 "{{ importRootPath }}/enum"
@@ -225,11 +248,17 @@ type Trailer struct {
225248{{ define "receiver" }}m{{ end }}
226249package {{ .Package }}
227250
228- import(
251+ import (
252+ {{- if collectStandardImports .MessageDef }}
253+ {{- range collectStandardImports .MessageDef }}
254+ "{{ . }}"
255+ {{- end }}{{ "\n" }}
256+ {{- end }}
257+ {{- if collectExtraImports .MessageDef }}
229258 {{- range collectExtraImports .MessageDef }}
230259 "{{ . }}"
260+ {{- end }}{{ "\n" }}
231261 {{- end }}
232-
233262 "github.com/quickfixgo/quickfix"
234263 {{- if checkIfEnumImportRequired .MessageDef}}
235264 "{{ importRootPath }}/enum"
@@ -297,23 +326,25 @@ func Route(router RouteOut) (string, string, quickfix.MessageRoute) {
297326
298327 TagTemplate = template .Must (template .New ("Tag" ).Parse (`
299328package tag
300- import( "github.com/quickfixgo/quickfix")
329+ import "github.com/quickfixgo/quickfix"
301330
302331const (
303332{{- range .}}
304- {{ .Name }} quickfix.Tag = {{ .Tag }}
333+ {{ .Name }} quickfix.Tag = {{ .Tag }}
305334{{- end }}
306335)
307336 ` ))
308337
309338 FieldTemplate = template .Must (template .New ("Field" ).Funcs (tmplFuncs ).Parse (`
310339package field
311- import(
340+ import (
341+ {{ if checkIfTimeImportRequiredForFields . }}"time"{{ end }}
342+
343+ {{ if checkIfDecimalImportRequiredForFields . }}"github.com/shopspring/decimal"{{ end }}
344+
312345 "github.com/quickfixgo/quickfix"
313346 "{{ importRootPath }}/enum"
314347 "{{ importRootPath }}/tag"
315- {{ if checkIfDecimalImportRequiredForFields . }} "github.com/shopspring/decimal" {{ end }}
316- {{ if checkIfTimeImportRequiredForFields . }} "time" {{ end }}
317348)
318349
319350{{ range . }}
0 commit comments