From c8196cefce95ea6e4627f308a9d166951bb8b3a5 Mon Sep 17 00:00:00 2001 From: ackleymi Date: Sun, 29 Sep 2019 19:05:40 -0400 Subject: [PATCH 1/6] Upgrades Go versions and migrates to modules. --- .travis.yml | 24 +++++++--- Gopkg.lock | 97 ---------------------------------------- Gopkg.toml | 34 -------------- dialer.go | 3 +- dialer_test.go | 5 ++- go.mod | 12 +++++ go.sum | 28 ++++++++++++ initiator.go | 3 +- mongostore_test.go | 5 ++- session_settings_test.go | 3 +- 10 files changed, 69 insertions(+), 145 deletions(-) delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml create mode 100644 go.mod create mode 100644 go.sum diff --git a/.travis.yml b/.travis.yml index 55955e15c..5849b2f95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,18 @@ language: go sudo: false -go: - - 1.9 - - tip - services: - mongodb +go: + - 1.11.x + - 1.12.x + - 1.13 + - tip + env: global: + - GO111MODULE=on - MONGODB_TEST_CXN=localhost matrix: - FIX_TEST= @@ -25,9 +28,16 @@ env: matrix: allow_failures: - go: tip + fast_finish: true + exclude: + - go: 1.13.x + env: GO111MODULE=on + - go: tip + env: GO111MODULE=on -install: - - go get -u github.com/golang/dep/cmd/dep - - dep ensure +before_install: + - if [[ "${GO111MODULE}" = "on" ]]; then mkdir "${HOME}/go"; export GOPATH="${HOME}/go"; fi + - if [[ "${GO111MODULE}" = "on" ]]; then export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"; fi + - go mod download script: make generate; if [ -z "$FIX_TEST" ]; then make build; make; else make build_accept; make $FIX_TEST; fi diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index 1504285e2..000000000 --- a/Gopkg.lock +++ /dev/null @@ -1,97 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - digest = "1:56c130d885a4aacae1dd9c7b71cfe39912c7ebc1ff7d2b46083c8812996dc43b" - name = "github.com/davecgh/go-spew" - packages = ["spew"] - pruneopts = "" - revision = "346938d642f2ec3594ed81d874461961cd0faa76" - version = "v1.1.0" - -[[projects]] - branch = "master" - digest = "1:e9ffb9315dce0051beb757d0f0fc25db57c4da654efc4eada4ea109c2d9da815" - name = "github.com/globalsign/mgo" - packages = [ - ".", - "bson", - "internal/json", - "internal/sasl", - "internal/scram", - ] - pruneopts = "" - revision = "eeefdecb41b842af6dc652aaea4026e8403e62df" - -[[projects]] - digest = "1:1cc12f4618ce8d71ca28ef3708f4e98e1318ab6f06ecfffb6781b893f271c89c" - name = "github.com/mattn/go-sqlite3" - packages = ["."] - pruneopts = "" - revision = "ca5e3819723d8eeaf170ad510e7da1d6d2e94a08" - version = "v1.2.0" - -[[projects]] - digest = "1:256484dbbcd271f9ecebc6795b2df8cad4c458dd0f5fd82a8c2fa0c29f233411" - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - pruneopts = "" - revision = "792786c7400a136282c1664665ae0a8db921c6c2" - version = "v1.0.0" - -[[projects]] - branch = "master" - digest = "1:68a81aa25065b50a4bf1ffd115ff3634704f61f675d0140b31492e9fcca55421" - name = "github.com/shopspring/decimal" - packages = ["."] - pruneopts = "" - revision = "aed1bfe463fa3c9cc268d60dcc1491db613bff7e" - -[[projects]] - branch = "master" - digest = "1:ed7ac53c7d59041f27964d3f04e021b45ecb5f23c842c84d778a7f1fb67e2ce9" - name = "github.com/stretchr/objx" - packages = ["."] - pruneopts = "" - revision = "1a9d0bb9f541897e62256577b352fdbc1fb4fd94" - -[[projects]] - digest = "1:3926a4ec9a4ff1a072458451aa2d9b98acd059a45b38f7335d31e06c3d6a0159" - name = "github.com/stretchr/testify" - packages = [ - "assert", - "mock", - "require", - "suite", - ] - pruneopts = "" - revision = "69483b4bd14f5845b5a1e55bca19e954e827f1d0" - version = "v1.1.4" - -[[projects]] - branch = "master" - digest = "1:898bc7c802c1e0c20cecd65811e90b7b9bc5651b4a07aefd159451bfb200b2b3" - name = "golang.org/x/net" - packages = [ - "context", - "proxy", - ] - pruneopts = "" - revision = "a04bdaca5b32abe1c069418fb7088ae607de5bd0" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = [ - "github.com/globalsign/mgo", - "github.com/globalsign/mgo/bson", - "github.com/mattn/go-sqlite3", - "github.com/shopspring/decimal", - "github.com/stretchr/testify/assert", - "github.com/stretchr/testify/mock", - "github.com/stretchr/testify/require", - "github.com/stretchr/testify/suite", - "golang.org/x/net/proxy", - ] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 3385a5e25..000000000 --- a/Gopkg.toml +++ /dev/null @@ -1,34 +0,0 @@ - -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" - - -[[constraint]] - name = "github.com/mattn/go-sqlite3" - version = "1.2.0" - -[[constraint]] - name = "github.com/shopspring/decimal" - branch = "master" - -[[constraint]] - name = "github.com/stretchr/testify" - version = "1.1.4" diff --git a/dialer.go b/dialer.go index 610fc1aeb..1645076bf 100644 --- a/dialer.go +++ b/dialer.go @@ -2,9 +2,10 @@ package quickfix import ( "fmt" + "net" + "github.com/quickfixgo/quickfix/config" "golang.org/x/net/proxy" - "net" ) func loadDialerConfig(settings *SessionSettings) (dialer proxy.Dialer, err error) { diff --git a/dialer_test.go b/dialer_test.go index 5e06b82cc..510c18f04 100644 --- a/dialer_test.go +++ b/dialer_test.go @@ -1,11 +1,12 @@ package quickfix import ( - "github.com/quickfixgo/quickfix/config" - "github.com/stretchr/testify/suite" "net" "testing" "time" + + "github.com/quickfixgo/quickfix/config" + "github.com/stretchr/testify/suite" ) type DialerTestSuite struct { diff --git a/go.mod b/go.mod new file mode 100644 index 000000000..35dc6871d --- /dev/null +++ b/go.mod @@ -0,0 +1,12 @@ +module github.com/quickfixgo/quickfix + +go 1.13 + +require ( + github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 + github.com/mattn/go-sqlite3 v1.11.0 + github.com/shopspring/decimal v0.0.0-20190905144223-a36b5d85f337 + github.com/stretchr/testify v1.4.0 + golang.org/x/net v0.0.0-20190926025831-c00fd9afed17 + golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 000000000..cfd41efd9 --- /dev/null +++ b/go.sum @@ -0,0 +1,28 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= +github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q= +github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/shopspring/decimal v0.0.0-20190905144223-a36b5d85f337 h1:Da9XEUfFxgyDOqUfwgoTDcWzmnlOnCGi6i4iPS+8Fbw= +github.com/shopspring/decimal v0.0.0-20190905144223-a36b5d85f337/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190926025831-c00fd9afed17 h1:qPnAdmjNA41t3QBTx2mFGf/SD1IoslhYu7AmdsVzCcs= +golang.org/x/net v0.0.0-20190926025831-c00fd9afed17/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e h1:1xWUkZQQ9Z9UuZgNaIR6OQOE7rUFglXUUBZlO+dGg6I= +golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/initiator.go b/initiator.go index 2ce02ace5..c84ced741 100644 --- a/initiator.go +++ b/initiator.go @@ -3,9 +3,10 @@ package quickfix import ( "bufio" "crypto/tls" - "golang.org/x/net/proxy" "sync" "time" + + "golang.org/x/net/proxy" ) //Initiator initiates connections and processes messages for all sessions. diff --git a/mongostore_test.go b/mongostore_test.go index 21ca84a8d..29d43d71d 100644 --- a/mongostore_test.go +++ b/mongostore_test.go @@ -2,12 +2,13 @@ package quickfix import ( "fmt" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" "log" "os" "strings" "testing" + + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" ) // MongoStoreTestSuite runs all tests in the MessageStoreTestSuite against the MongoStore implementation diff --git a/session_settings_test.go b/session_settings_test.go index a28f60529..34687ae2c 100644 --- a/session_settings_test.go +++ b/session_settings_test.go @@ -1,8 +1,9 @@ package quickfix import ( - "github.com/quickfixgo/quickfix/config" "testing" + + "github.com/quickfixgo/quickfix/config" ) func TestSessionSettings_StringSettings(t *testing.T) { From c9d06ba5abc677b34cd991767290af4501446390 Mon Sep 17 00:00:00 2001 From: ackleymi Date: Mon, 30 Sep 2019 00:28:08 -0400 Subject: [PATCH 2/6] Adds gopath requirement hack and canonicalizes template comment format. --- Makefile | 5 ++- cmd/generate-fix/generate-fix.go | 28 +++++++------- cmd/generate-fix/internal/helpers.go | 23 +++++------- cmd/generate-fix/internal/templates.go | 52 +++++++++++++------------- go.mod | 1 - go.sum | 5 --- 6 files changed, 54 insertions(+), 60 deletions(-) diff --git a/Makefile b/Makefile index d513ded8a..c883e5bd0 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ all: vet test -generate: +clean: + rm -rf gen + +generate: clean mkdir -p gen; cd gen; go run ../cmd/generate-fix/generate-fix.go ../spec/*.xml generate-dist: diff --git a/cmd/generate-fix/generate-fix.go b/cmd/generate-fix/generate-fix.go index 5ec5ff47a..458e20458 100644 --- a/cmd/generate-fix/generate-fix.go +++ b/cmd/generate-fix/generate-fix.go @@ -101,7 +101,7 @@ func genEnums() { } func gen(t *template.Template, fileOut string, data interface{}) { - defer waitGroup.Done() + //defer waitGroup.Done() writer := new(bytes.Buffer) if err := t.Execute(writer, data); err != nil { @@ -133,12 +133,12 @@ func main() { internal.BuildGlobalFieldTypes(specs) - waitGroup.Add(1) - go genTags() - waitGroup.Add(1) - go genFields() - waitGroup.Add(1) - go genEnums() + //waitGroup.Add(1) + genTags() + //waitGroup.Add(1) + genFields() + //waitGroup.Add(1) + genEnums() for _, spec := range specs { pkg := getPackageName(spec) @@ -155,21 +155,21 @@ func main() { //uses fixt11 header/trailer case "fix50", "fix50sp1", "fix50sp2": default: - waitGroup.Add(1) - go genHeader(pkg, spec) + //waitGroup.Add(1) + genHeader(pkg, spec) - waitGroup.Add(1) - go genTrailer(pkg, spec) + //waitGroup.Add(1) + genTrailer(pkg, spec) } for _, m := range spec.Messages { - waitGroup.Add(1) - go genMessage(pkg, spec, m) + //waitGroup.Add(1) + genMessage(pkg, spec, m) } } go func() { - waitGroup.Wait() + //waitGroup.Wait() close(errors) }() diff --git a/cmd/generate-fix/internal/helpers.go b/cmd/generate-fix/internal/helpers.go index dba773d89..33f491a4d 100644 --- a/cmd/generate-fix/internal/helpers.go +++ b/cmd/generate-fix/internal/helpers.go @@ -1,21 +1,18 @@ package internal -import ( - "os" - "path/filepath" - "strings" -) - // getImportPathRoot returns the root path to use in import statements. // The root path is determined by stripping "$GOPATH/src/" from the current // working directory. For example, when generating code within the QuickFIX/Go // source tree, the returned root path will be "github.com/quickfixgo/quickfix". func getImportPathRoot() string { - pwd, err := os.Getwd() - if err != nil { - panic(err) - } - goSrcPath := filepath.Join(os.Getenv("GOPATH"), "src") - importPathRoot := filepath.ToSlash(strings.Replace(pwd, goSrcPath, "", 1)) - return strings.TrimLeft(importPathRoot, "/") + // pwd, err := os.Getwd() + // if err != nil { + // panic(err) + // } + // goSrcPath := filepath.Join(os.Getenv("GOPATH"), "src") + // importPathRoot := filepath.ToSlash(strings.Replace(pwd, goSrcPath, "", 1)) + // return strings.TrimLeft(importPathRoot, "/") + + // !! A hack for now? ..... + return "github.com/quickfixgo/quickfix/gen" } diff --git a/cmd/generate-fix/internal/templates.go b/cmd/generate-fix/internal/templates.go index 95aa5276e..cae2d567d 100644 --- a/cmd/generate-fix/internal/templates.go +++ b/cmd/generate-fix/internal/templates.go @@ -57,7 +57,7 @@ Set{{ .Name }}(f {{ .Name }}RepeatingGroup){ {{ define "setters" }} {{ range .Fields }} -//Set{{ .Name }} sets {{ .Name }}, Tag {{ .Tag }} +// Set{{ .Name }} sets {{ .Name }}, Tag {{ .Tag }}. func ({{ template "receiver" }} {{ $.Name }}) {{ if .IsGroup }}{{ template "groupsetter" . }}{{ else }}{{ template "fieldsetter" . }}{{ end }} {{ end }}{{ end }} @@ -97,13 +97,13 @@ Get{{ .Name }}() ({{ .Name }}RepeatingGroup, quickfix.MessageRejectError) { {{ define "getters" }} {{ range .Fields }} -//Get{{ .Name }} gets {{ .Name }}, Tag {{ .Tag }} +// Get{{ .Name }} gets {{ .Name }}, Tag {{ .Tag }}. func ({{ template "receiver" }} {{ $.Name }}) {{if .IsGroup}}{{ template "groupgetter" . }}{{ else }}{{ template "fieldvaluegetter" .}}{{ end }} {{ end }}{{ end }} {{ define "hasers" }} {{range .Fields}} -//Has{{ .Name}} returns true if {{ .Name}} is present, Tag {{ .Tag}} +// Has{{ .Name}} returns true if {{ .Name}} is present, Tag {{ .Tag}}. func ({{ template "receiver" }} {{ $.Name }}) Has{{ .Name}}() bool { return {{ template "receiver" }}.Has(tag.{{ .Name}}) } @@ -121,7 +121,7 @@ quickfix.GroupTemplate{ {{ define "groups" }} {{ range .Fields }} {{ if .IsGroup }} -//{{ .Name }} is a repeating group element, Tag {{ .Tag }} +// {{ .Name }} is a repeating group element, Tag {{ .Tag }}. type {{ .Name }} struct { *quickfix.Group } @@ -131,24 +131,24 @@ type {{ .Name }} struct { {{ template "hasers" . }} {{ template "groups" . }} -//{{ .Name }}RepeatingGroup is a repeating group, Tag {{ .Tag }} +// {{ .Name }}RepeatingGroup is a repeating group, Tag {{ .Tag }}. type {{ .Name }}RepeatingGroup struct { *quickfix.RepeatingGroup } -//New{{ .Name }}RepeatingGroup returns an initialized, {{ .Name }}RepeatingGroup +// New{{ .Name }}RepeatingGroup returns an initialized, {{ .Name }}RepeatingGroup. func New{{ .Name }}RepeatingGroup() {{ .Name }}RepeatingGroup { return {{ .Name }}RepeatingGroup{ quickfix.NewRepeatingGroup(tag.{{ .Name }}, {{ template "group_template" .Fields }})} } -//Add create and append a new {{ .Name }} to this group +// Add create and append a new {{ .Name }} to this group. func ({{ template "receiver" }} {{ .Name }}RepeatingGroup) Add() {{ .Name }} { g := {{ template "receiver" }}.RepeatingGroup.Add() return {{ .Name }}{g} } -//Get returns the ith {{ .Name }} in the {{ .Name }}RepeatinGroup +// Get returns the ith {{ .Name }} in the {{ .Name }}RepeatinGroup. func ({{ template "receiver" }} {{ .Name}}RepeatingGroup) Get(i int) {{ .Name }} { return {{ .Name }}{ {{ template "receiver" }}.RepeatingGroup.Get(i) } } @@ -174,12 +174,12 @@ import( "{{ importRootPath }}/tag" ) -//Header is the {{ .Package }} Header type +// Header is the {{ .Package }} Header type. type Header struct { *quickfix.Header } -//NewHeader returns a new, initialized Header instance +// NewHeader returns a new, initialized Header instance. func NewHeader(header *quickfix.Header) (h Header) { h.Header = header h.SetBeginString("{{ beginString .FIXSpec }}") @@ -209,7 +209,7 @@ import( "{{ importRootPath }}/tag" ) -//Trailer is the {{ .Package }} Trailer type +// Trailer is the {{ .Package }} Trailer type. type Trailer struct { *quickfix.Trailer } @@ -238,7 +238,7 @@ import( "{{ importRootPath }}/tag" ) -//{{ .Name }} is the {{ .FIXPackage }} {{ .Name }} type, MsgType = {{ .MsgType }} +// {{ .Name }} is the {{ .FIXPackage }} {{ .Name }} type, MsgType = {{ .MsgType }}. type {{ .Name }} struct { {{ .TransportPackage }}.Header *quickfix.Body @@ -246,7 +246,7 @@ type {{ .Name }} struct { Message *quickfix.Message } -//FromMessage creates a {{ .Name }} from a quickfix.Message instance +// FromMessage creates a {{ .Name }} from a quickfix.Message instance. func FromMessage(m *quickfix.Message) {{ .Name }} { return {{ .Name }}{ Header: {{ .TransportPackage}}.Header{&m.Header}, @@ -256,13 +256,13 @@ func FromMessage(m *quickfix.Message) {{ .Name }} { } } -//ToMessage returns a quickfix.Message instance +// ToMessage returns a quickfix.Message instance. func (m {{ .Name }}) ToMessage() *quickfix.Message { return m.Message } {{ $required_fields := requiredFields .MessageDef -}} -//New returns a {{ .Name }} initialized with the required fields for {{ .Name }} +// New returns a {{ .Name }} initialized with the required fields for {{ .Name }}. func New({{template "field_args" $required_fields }}) (m {{ .Name }}) { m.Message = quickfix.NewMessage() m.Header = {{ .TransportPackage }}.NewHeader(&m.Message.Header) @@ -277,10 +277,10 @@ func New({{template "field_args" $required_fields }}) (m {{ .Name }}) { return } -//A RouteOut is the callback type that should be implemented for routing Message +// A RouteOut is the callback type that should be implemented for routing Message. type RouteOut func(msg {{ .Name }}, sessionID quickfix.SessionID) quickfix.MessageRejectError -//Route returns the beginstring, message type, and MessageRoute for this Message type +// Route returns the beginstring, message type, and MessageRoute for this Message type. func Route(router RouteOut) (string, string, quickfix.MessageRoute) { r:=func(msg *quickfix.Message, sessionID quickfix.SessionID) quickfix.MessageRejectError { return router(FromMessage(msg), sessionID) @@ -319,28 +319,28 @@ import( {{- $base_type := quickfixType . -}} {{ if and .Enums (ne $base_type "FIXBoolean") }} -//{{ .Name }}Field is a enum.{{ .Name }} field +// {{ .Name }}Field is a enum.{{ .Name }} field. type {{ .Name }}Field struct { quickfix.FIXString } {{ else }} -//{{ .Name }}Field is a {{ .Type }} field +// {{ .Name }}Field is a {{ .Type }} field. type {{ .Name }}Field struct { quickfix.{{ $base_type }} } {{ end }} -//Tag returns tag.{{ .Name }} ({{ .Tag }}) +// Tag returns tag.{{ .Name }} ({{ .Tag }}). func (f {{ .Name }}Field) Tag() quickfix.Tag { return tag.{{ .Name }} } {{ if eq $base_type "FIXUTCTimestamp" }} -//New{{ .Name }} returns a new {{ .Name }}Field initialized with val +// New{{ .Name }} returns a new {{ .Name }}Field initialized with val. func New{{ .Name }}(val time.Time) {{ .Name }}Field { return New{{ .Name }}WithPrecision(val, quickfix.Millis) } -//New{{ .Name }}NoMillis returns a new {{ .Name }}Field initialized with val without millisecs +// New{{ .Name }}NoMillis returns a new {{ .Name }}Field initialized with val without millisecs. func New{{ .Name }}NoMillis(val time.Time) {{ .Name }}Field { return New{{ .Name }}WithPrecision(val, quickfix.Seconds) } -//New{{ .Name }}WithPrecision returns a new {{ .Name }}Field initialized with val of specified precision +// New{{ .Name }}WithPrecision returns a new {{ .Name }}Field initialized with val of specified precision. func New{{ .Name }}WithPrecision(val time.Time, precision quickfix.TimestampPrecision) {{ .Name }}Field { return {{ .Name }}Field{ quickfix.FIXUTCTimestamp{ Time: val, Precision: precision } } } @@ -350,12 +350,12 @@ func New{{ .Name }}(val enum.{{ .Name }}) {{ .Name }}Field { return {{ .Name }}Field{ quickfix.FIXString(val) } } {{ else if eq $base_type "FIXDecimal" }} -//New{{ .Name }} returns a new {{ .Name }}Field initialized with val and scale +// New{{ .Name }} returns a new {{ .Name }}Field initialized with val and scale. func New{{ .Name }}(val decimal.Decimal, scale int32) {{ .Name }}Field { return {{ .Name }}Field{ quickfix.FIXDecimal{ Decimal: val, Scale: scale} } } {{ else }} -//New{{ .Name }} returns a new {{ .Name }}Field initialized with val +// New{{ .Name }} returns a new {{ .Name }}Field initialized with val. func New{{ .Name }}(val {{ quickfixValueType $base_type }}) {{ .Name }}Field { return {{ .Name }}Field{ quickfix.{{ $base_type }}(val) } } @@ -386,7 +386,7 @@ func (f {{ .Name }}Field) Value() ({{ quickfixValueType $base_type }}) { package enum {{ range $ft := . }} {{ if $ft.Enums }} -//Enum values for {{ $ft.Name }} +// {{ $ft.Name }} field enumeration values. type {{ $ft.Name }} string const( {{ range $ft.Enums }} diff --git a/go.mod b/go.mod index 35dc6871d..7a1c07b7d 100644 --- a/go.mod +++ b/go.mod @@ -8,5 +8,4 @@ require ( github.com/shopspring/decimal v0.0.0-20190905144223-a36b5d85f337 github.com/stretchr/testify v1.4.0 golang.org/x/net v0.0.0-20190926025831-c00fd9afed17 - golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e // indirect ) diff --git a/go.sum b/go.sum index cfd41efd9..ee9f475a9 100644 --- a/go.sum +++ b/go.sum @@ -13,15 +13,10 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190926025831-c00fd9afed17 h1:qPnAdmjNA41t3QBTx2mFGf/SD1IoslhYu7AmdsVzCcs= golang.org/x/net v0.0.0-20190926025831-c00fd9afed17/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e h1:1xWUkZQQ9Z9UuZgNaIR6OQOE7rUFglXUUBZlO+dGg6I= -golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= From 1b43940d5626673867e1f8d61312a2ef6fdb074e Mon Sep 17 00:00:00 2001 From: ackleymi Date: Thu, 17 Oct 2019 22:40:53 -0400 Subject: [PATCH 3/6] Adds a flag to specify generated package import paths. --- cmd/generate-fix/internal/generate.go | 1 + cmd/generate-fix/internal/helpers.go | 14 +------------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/cmd/generate-fix/internal/generate.go b/cmd/generate-fix/internal/generate.go index 9fbefea29..3dc428980 100644 --- a/cmd/generate-fix/internal/generate.go +++ b/cmd/generate-fix/internal/generate.go @@ -13,6 +13,7 @@ import ( var ( useFloat = flag.Bool("use-float", false, "By default, FIX float fields are represented as arbitrary-precision fixed-point decimal numbers. Set to 'true' to instead generate FIX float fields as float64 values.") + pkgRoot = flag.String("pkg-root", "github.com/quickfixgo", "Set a string here to provide a custom import path for generated packages.") tabWidth = 8 printerMode = printer.UseSpaces | printer.TabIndent ) diff --git a/cmd/generate-fix/internal/helpers.go b/cmd/generate-fix/internal/helpers.go index 33f491a4d..8fe4cd4c6 100644 --- a/cmd/generate-fix/internal/helpers.go +++ b/cmd/generate-fix/internal/helpers.go @@ -1,18 +1,6 @@ package internal // getImportPathRoot returns the root path to use in import statements. -// The root path is determined by stripping "$GOPATH/src/" from the current -// working directory. For example, when generating code within the QuickFIX/Go -// source tree, the returned root path will be "github.com/quickfixgo/quickfix". func getImportPathRoot() string { - // pwd, err := os.Getwd() - // if err != nil { - // panic(err) - // } - // goSrcPath := filepath.Join(os.Getenv("GOPATH"), "src") - // importPathRoot := filepath.ToSlash(strings.Replace(pwd, goSrcPath, "", 1)) - // return strings.TrimLeft(importPathRoot, "/") - - // !! A hack for now? ..... - return "github.com/quickfixgo/quickfix/gen" + return *pkgRoot } From efbda9aa01196c1fcdcf5da274591cfb98708cbd Mon Sep 17 00:00:00 2001 From: ackleymi Date: Thu, 17 Oct 2019 22:41:32 -0400 Subject: [PATCH 4/6] Reverts generator waitgroup behavior. --- cmd/generate-fix/generate-fix.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/generate-fix/generate-fix.go b/cmd/generate-fix/generate-fix.go index 458e20458..9512d9a19 100644 --- a/cmd/generate-fix/generate-fix.go +++ b/cmd/generate-fix/generate-fix.go @@ -101,7 +101,7 @@ func genEnums() { } func gen(t *template.Template, fileOut string, data interface{}) { - //defer waitGroup.Done() + defer waitGroup.Done() writer := new(bytes.Buffer) if err := t.Execute(writer, data); err != nil { @@ -133,11 +133,11 @@ func main() { internal.BuildGlobalFieldTypes(specs) - //waitGroup.Add(1) + waitGroup.Add(1) genTags() - //waitGroup.Add(1) + waitGroup.Add(1) genFields() - //waitGroup.Add(1) + waitGroup.Add(1) genEnums() for _, spec := range specs { @@ -155,21 +155,21 @@ func main() { //uses fixt11 header/trailer case "fix50", "fix50sp1", "fix50sp2": default: - //waitGroup.Add(1) + waitGroup.Add(1) genHeader(pkg, spec) - //waitGroup.Add(1) + waitGroup.Add(1) genTrailer(pkg, spec) } for _, m := range spec.Messages { - //waitGroup.Add(1) + waitGroup.Add(1) genMessage(pkg, spec, m) } } go func() { - //waitGroup.Wait() + waitGroup.Wait() close(errors) }() From cfd1c5e83039e1166f62bf113dbd38fbee3d3bcf Mon Sep 17 00:00:00 2001 From: ackleymi Date: Fri, 18 Oct 2019 00:46:29 -0400 Subject: [PATCH 5/6] Updates README to reflect modules changes. --- README.md | 51 ++++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index f9a59056f..d615b4db7 100644 --- a/README.md +++ b/README.md @@ -54,24 +54,16 @@ Following installation, `generate-fix` is installed to `$GOPATH/bin/generate-fix Developing QuickFIX/Go ---------------------- -If you wish to work on QuickFIX/Go itself, you will first need [Go](http://www.golang.org) installed on your machine (version 1.6+ is *required*). +If you wish to work on QuickFIX/Go itself, you will first need [Go](http://www.golang.org) installed and configured on your machine (version 1.13+ is preferred, but the minimum required version is 1.6). -For local dev first make sure Go is properly installed, including setting up a [GOPATH](http://golang.org/doc/code.html#GOPATH). - -Next, using [Git](https://git-scm.com/), clone this repository into `$GOPATH/src/github.com/quickfixgo/quickfix`. +Next, using [Git](https://git-scm.com/), clone the repository via `git clone git@github.com:quickfixgo/quickfix.git` ### Installing Dependencies -QuickFIX/Go uses [dep](https://github.com/golang/dep) to manage the vendored dependencies. Install dep with `go get`: - -```sh -$ go get -u github.com/golang/dep/cmd/dep -``` - -Run `dep ensure` to install the correct versioned dependencies into `vendor/`, which Go 1.6+ automatically recognizes and loads. +As of Go version 1.13, QuickFIX/Go uses [modules](https://github.com/golang/go/wiki/Modules) to manage dependencies. You may require `GO111MODULE=on`. To install dependencies, run ```sh -$ $GOPATH/bin/dep ensure +go mod download ``` **Note:** No vendored dependencies are included in the QuickFIX/Go source. @@ -117,37 +109,22 @@ To run acceptance tests, If you are developing QuickFIX/Go, there are a few tasks you might need to perform related to dependencies. -#### Adding a dependency - -If you are adding a dependency, you will need to update the dep manifest in the same Pull Request as the code that depends on it. You should do this in a separate commit from your code, as this makes PR review easier and Git history simpler to read in the future. +#### Adding/updating a dependency -To add a dependency: - -1. Add the dependency using `dep`: -```bash -$ dep ensure -add github.com/foo/bar -``` -2. Review the changes in git and commit them. +If you are adding or updating a dependency, you will need to update the `go.mod` and `go.sum` in the same Pull Request as the code that depends on it. You should do this in a separate commit from your code, as this makes PR review easier and Git history simpler to read in the future. -#### Updating a dependency - -To update a dependency to the latest version allowed by constraints in `Gopkg.toml`: - -1. Run: -```bash -$ dep ensure -update github.com/foo/bar +1. Add or update the dependency like usual: +```sh +go get -u github.com/foo/bar ``` -2. Review the changes in git and commit them. - -To change the allowed version/branch/revision of a dependency: - -1. Manually edit `Gopkg.toml` -2. Run: -```bash -$ dep ensure +2. Update the module-related files: +```sh +go mod tidy ``` 3. Review the changes in git and commit them. +Note that to specify a specific revision, you can manually edit the `go.mod` file and run `go mod tidy` + Licensing --------- From 5d74fbcade2b802745ab7380c6b09b311c890fb7 Mon Sep 17 00:00:00 2001 From: ackleymi Date: Wed, 23 Oct 2019 21:43:53 -0400 Subject: [PATCH 6/6] Restores go expressions to generator funcs. --- cmd/generate-fix/generate-fix.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/generate-fix/generate-fix.go b/cmd/generate-fix/generate-fix.go index 9512d9a19..5ec5ff47a 100644 --- a/cmd/generate-fix/generate-fix.go +++ b/cmd/generate-fix/generate-fix.go @@ -134,11 +134,11 @@ func main() { internal.BuildGlobalFieldTypes(specs) waitGroup.Add(1) - genTags() + go genTags() waitGroup.Add(1) - genFields() + go genFields() waitGroup.Add(1) - genEnums() + go genEnums() for _, spec := range specs { pkg := getPackageName(spec) @@ -156,15 +156,15 @@ func main() { case "fix50", "fix50sp1", "fix50sp2": default: waitGroup.Add(1) - genHeader(pkg, spec) + go genHeader(pkg, spec) waitGroup.Add(1) - genTrailer(pkg, spec) + go genTrailer(pkg, spec) } for _, m := range spec.Messages { waitGroup.Add(1) - genMessage(pkg, spec, m) + go genMessage(pkg, spec, m) } }