Skip to content

Commit 9ac32c8

Browse files
authored
Merge pull request #381 from ackleymi/master
Adds Go module support
2 parents 7d001a9 + 5d74fbc commit 9ac32c8

File tree

15 files changed

+109
-225
lines changed

15 files changed

+109
-225
lines changed

.travis.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
language: go
22
sudo: false
33

4-
go:
5-
- 1.9
6-
- tip
7-
84
services:
95
- mongodb
106

7+
go:
8+
- 1.11.x
9+
- 1.12.x
10+
- 1.13
11+
- tip
12+
1113
env:
1214
global:
15+
- GO111MODULE=on
1316
- MONGODB_TEST_CXN=localhost
1417
matrix:
1518
- FIX_TEST=
@@ -25,9 +28,16 @@ env:
2528
matrix:
2629
allow_failures:
2730
- go: tip
31+
fast_finish: true
32+
exclude:
33+
- go: 1.13.x
34+
env: GO111MODULE=on
35+
- go: tip
36+
env: GO111MODULE=on
2837

29-
install:
30-
- go get -u github.com/golang/dep/cmd/dep
31-
- dep ensure
38+
before_install:
39+
- if [[ "${GO111MODULE}" = "on" ]]; then mkdir "${HOME}/go"; export GOPATH="${HOME}/go"; fi
40+
- if [[ "${GO111MODULE}" = "on" ]]; then export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"; fi
41+
- go mod download
3242

3343
script: make generate; if [ -z "$FIX_TEST" ]; then make build; make; else make build_accept; make $FIX_TEST; fi

Gopkg.lock

Lines changed: 0 additions & 97 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 34 deletions
This file was deleted.

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
all: vet test
22

3-
generate:
3+
clean:
4+
rm -rf gen
5+
6+
generate: clean
47
mkdir -p gen; cd gen; go run ../cmd/generate-fix/generate-fix.go ../spec/*.xml
58

69
generate-dist:

README.md

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,16 @@ Following installation, `generate-fix` is installed to `$GOPATH/bin/generate-fix
5454
Developing QuickFIX/Go
5555
----------------------
5656

57-
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*).
57+
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).
5858

59-
For local dev first make sure Go is properly installed, including setting up a [GOPATH](http://golang.org/doc/code.html#GOPATH).
60-
61-
Next, using [Git](https://git-scm.com/), clone this repository into `$GOPATH/src/github.com/quickfixgo/quickfix`.
59+
Next, using [Git](https://git-scm.com/), clone the repository via `git clone git@github.com:quickfixgo/quickfix.git`
6260

6361
### Installing Dependencies
6462

65-
QuickFIX/Go uses [dep](https://github.com/golang/dep) to manage the vendored dependencies. Install dep with `go get`:
66-
67-
```sh
68-
$ go get -u github.com/golang/dep/cmd/dep
69-
```
70-
71-
Run `dep ensure` to install the correct versioned dependencies into `vendor/`, which Go 1.6+ automatically recognizes and loads.
63+
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
7264

7365
```sh
74-
$ $GOPATH/bin/dep ensure
66+
go mod download
7567
```
7668

7769
**Note:** No vendored dependencies are included in the QuickFIX/Go source.
@@ -117,37 +109,22 @@ To run acceptance tests,
117109

118110
If you are developing QuickFIX/Go, there are a few tasks you might need to perform related to dependencies.
119111

120-
#### Adding a dependency
121-
122-
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.
112+
#### Adding/updating a dependency
123113

124-
To add a dependency:
125-
126-
1. Add the dependency using `dep`:
127-
```bash
128-
$ dep ensure -add github.com/foo/bar
129-
```
130-
2. Review the changes in git and commit them.
114+
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.
131115

132-
#### Updating a dependency
133-
134-
To update a dependency to the latest version allowed by constraints in `Gopkg.toml`:
135-
136-
1. Run:
137-
```bash
138-
$ dep ensure -update github.com/foo/bar
116+
1. Add or update the dependency like usual:
117+
```sh
118+
go get -u github.com/foo/bar
139119
```
140-
2. Review the changes in git and commit them.
141-
142-
To change the allowed version/branch/revision of a dependency:
143-
144-
1. Manually edit `Gopkg.toml`
145-
2. Run:
146-
```bash
147-
$ dep ensure
120+
2. Update the module-related files:
121+
```sh
122+
go mod tidy
148123
```
149124
3. Review the changes in git and commit them.
150125

126+
Note that to specify a specific revision, you can manually edit the `go.mod` file and run `go mod tidy`
127+
151128
Licensing
152129
---------
153130

cmd/generate-fix/internal/generate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
var (
1515
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.")
16+
pkgRoot = flag.String("pkg-root", "github.com/quickfixgo", "Set a string here to provide a custom import path for generated packages.")
1617
tabWidth = 8
1718
printerMode = printer.UseSpaces | printer.TabIndent
1819
)
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
package internal
22

3-
import (
4-
"os"
5-
"path/filepath"
6-
"strings"
7-
)
8-
93
// getImportPathRoot returns the root path to use in import statements.
10-
// The root path is determined by stripping "$GOPATH/src/" from the current
11-
// working directory. For example, when generating code within the QuickFIX/Go
12-
// source tree, the returned root path will be "github.com/quickfixgo/quickfix".
134
func getImportPathRoot() string {
14-
pwd, err := os.Getwd()
15-
if err != nil {
16-
panic(err)
17-
}
18-
goSrcPath := filepath.Join(os.Getenv("GOPATH"), "src")
19-
importPathRoot := filepath.ToSlash(strings.Replace(pwd, goSrcPath, "", 1))
20-
return strings.TrimLeft(importPathRoot, "/")
5+
return *pkgRoot
216
}

0 commit comments

Comments
 (0)