@@ -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 "checkIfEnumImportRequired" : checkIfEnumImportRequired ,
@@ -111,7 +112,14 @@ func ({{ template "receiver" }} {{ $.Name }}) Has{{ .Name}}() bool {
111112
112113{{ define "group_template" }}
113114quickfix.GroupTemplate{
114- {{- range $index, $field := . }}{{if $index}},{{end}}{{if $field.IsGroup }}New{{ $field.Name }}RepeatingGroup(){{else}}quickfix.GroupElement(tag.{{$field.Name}}){{ end }}{{ end }} }
115+ {{- range $index, $field := . }}
116+ {{- if $field.IsGroup }}
117+ New{{ $field.Name }}RepeatingGroup(),
118+ {{- else}}
119+ quickfix.GroupElement(tag.{{$field.Name}}),
120+ {{- end }}
121+ {{- end }}
122+ }
115123{{- end }}
116124
117125{{ define "field_args" }}
@@ -139,7 +147,11 @@ type {{ .Name }}RepeatingGroup struct {
139147// New{{ .Name }}RepeatingGroup returns an initialized, {{ .Name }}RepeatingGroup.
140148func New{{ .Name }}RepeatingGroup() {{ .Name }}RepeatingGroup {
141149 return {{ .Name }}RepeatingGroup{
142- quickfix.NewRepeatingGroup(tag.{{ .Name }}, {{ template "group_template" .Fields }})}
150+ quickfix.NewRepeatingGroup(
151+ tag.{{ .Name }},
152+ {{- template "group_template" .Fields }},
153+ ),
154+ }
143155}
144156
145157// Add create and append a new {{ .Name }} to this group.
@@ -160,12 +172,17 @@ func ({{ template "receiver" }} {{ .Name}}RepeatingGroup) Get(i int) {{ .Name }}
160172{{ define "receiver" }}h{{ end }}
161173package {{ .Package }}
162174
163- import(
175+ import (
176+ {{- if collectStandardImports .MessageDef }}
177+ {{- range collectStandardImports .MessageDef }}
178+ "{{ . }}"
179+ {{- end }}{{ "\n" }}
180+ {{- end }}
181+ {{- if collectExtraImports .MessageDef }}
164182 {{- range collectExtraImports .MessageDef }}
165183 "{{ . }}"
184+ {{- end }}{{ "\n" }}
166185 {{- end }}
167-
168-
169186 "github.com/quickfixgo/quickfix"
170187 {{- if checkIfEnumImportRequired .MessageDef}}
171188 "{{ importRootPath }}/enum"
@@ -196,11 +213,17 @@ func NewHeader(header *quickfix.Header) (h Header) {
196213{{ define "receiver" }}t{{ end }}
197214package {{ .Package }}
198215
199- import(
216+ import (
217+ {{- if collectStandardImports .MessageDef }}
218+ {{- range collectStandardImports .MessageDef }}
219+ "{{ . }}"
220+ {{- end }}{{ "\n" }}
221+ {{- end }}
222+ {{- if collectExtraImports .MessageDef }}
200223 {{- range collectExtraImports .MessageDef }}
201224 "{{ . }}"
225+ {{- end }}{{ "\n" }}
202226 {{- end }}
203-
204227 "github.com/quickfixgo/quickfix"
205228 {{- if checkIfEnumImportRequired .MessageDef}}
206229 "{{ importRootPath }}/enum"
@@ -224,11 +247,17 @@ type Trailer struct {
224247{{ define "receiver" }}m{{ end }}
225248package {{ .Package }}
226249
227- import(
250+ import (
251+ {{- if collectStandardImports .MessageDef }}
252+ {{- range collectStandardImports .MessageDef }}
253+ "{{ . }}"
254+ {{- end }}{{ "\n" }}
255+ {{- end }}
256+ {{- if collectExtraImports .MessageDef }}
228257 {{- range collectExtraImports .MessageDef }}
229258 "{{ . }}"
259+ {{- end }}{{ "\n" }}
230260 {{- end }}
231-
232261 "github.com/quickfixgo/quickfix"
233262 {{- if checkIfEnumImportRequired .MessageDef}}
234263 "{{ importRootPath }}/enum"
@@ -296,23 +325,25 @@ func Route(router RouteOut) (string, string, quickfix.MessageRoute) {
296325
297326 TagTemplate = template .Must (template .New ("Tag" ).Parse (`
298327package tag
299- import( "github.com/quickfixgo/quickfix")
328+ import "github.com/quickfixgo/quickfix"
300329
301330const (
302331{{- range .}}
303- {{ .Name }} quickfix.Tag = {{ .Tag }}
332+ {{ .Name }} quickfix.Tag = {{ .Tag }}
304333{{- end }}
305334)
306335 ` ))
307336
308337 FieldTemplate = template .Must (template .New ("Field" ).Funcs (tmplFuncs ).Parse (`
309338package field
310- import(
339+ import (
340+ "time"
341+
342+ {{ if checkIfDecimalImportRequiredForFields . }}"github.com/shopspring/decimal"{{ end }}
343+
311344 "github.com/quickfixgo/quickfix"
312345 "{{ importRootPath }}/enum"
313346 "{{ importRootPath }}/tag"
314- {{ if checkIfDecimalImportRequiredForFields . }} "github.com/shopspring/decimal" {{ end }}
315- "time"
316347)
317348
318349{{ range . }}
0 commit comments