Skip to content

Commit 0aa61fd

Browse files
authored
Merge pull request #498 from quickfixgo/fix-linting
Adds linter fixes and upgrades go version to 1.18
2 parents 006218f + c74764c commit 0aa61fd

32 files changed

+225
-65
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM mcr.microsoft.com/vscode/devcontainers/go:0-1.18

.devcontainer/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "Go & Mongo DB",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "app",
5+
"workspaceFolder": "/workspace",
6+
"runArgs": [
7+
"--cap-add=SYS_PTRACE",
8+
"--security-opt",
9+
"seccomp=unconfined"
10+
],
11+
"customizations": {
12+
"vscode": {
13+
"settings": {
14+
"go.toolsManagement.checkForUpdates": "local",
15+
"go.useLanguageServer": true,
16+
"go.gopath": "/go"
17+
},
18+
"extensions": [
19+
"golang.Go",
20+
"mongodb.mongodb-vscode"
21+
]
22+
}
23+
},
24+
"remoteUser": "vscode"
25+
}

.devcontainer/docker-compose.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
volumes:
9+
- ..:/workspace:cached
10+
11+
# Overrides default command so things don't shut down after the process ends.
12+
command: sleep infinity
13+
14+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
15+
network_mode: service:db
16+
17+
# Uncomment the next line to use a non-root user for all processes.
18+
# user: node
19+
20+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
21+
# (Adding the "ports" property to this file will not forward from a Codespace.)
22+
23+
db:
24+
image: mongo:latest
25+
restart: unless-stopped
26+
volumes:
27+
- mongodb-data:/data/db
28+
29+
# Uncomment to change startup options
30+
# environment:
31+
# MONGO_INITDB_ROOT_USERNAME: root
32+
# MONGO_INITDB_ROOT_PASSWORD: example
33+
# MONGO_INITDB_DATABASE: your-database-here
34+
35+
# Add "forwardPorts": ["27017"] to **devcontainer.json** to forward MongoDB locally.
36+
# (Adding the "ports" property to this file will not forward from a Codespace.)
37+
38+
volumes:
39+
mongodb-data:

.github/workflows/ci.yaml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,34 @@ jobs:
1818
permissions:
1919
contents: read # for actions/checkout to fetch code
2020
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
21-
name: lint
21+
name: Linter
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v2
25-
- name: golangci-lint
26-
uses: golangci/golangci-lint-action@v2
24+
- name: Checkout source code
25+
uses: actions/checkout@v2
26+
- name: Setup Go
27+
uses: actions/setup-go@v2
2728
with:
28-
version: v1.41
29+
go-version: '1.18'
30+
- name: Install golangci-lint
31+
run: |
32+
curl -sSLO https://github.com/golangci/golangci-lint/releases/download/v$GOLANGCI_LINT_VERSION/golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64.tar.gz
33+
shasum -a 256 golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64.tar.gz | grep "^$GOLANGCI_LINT_SHA256 " > /dev/null
34+
tar -xf golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64.tar.gz
35+
sudo mv golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64/golangci-lint /usr/local/bin/golangci-lint
36+
rm -rf golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64*
37+
env:
38+
GOLANGCI_LINT_VERSION: '1.46.2'
39+
GOLANGCI_LINT_SHA256: '242cd4f2d6ac0556e315192e8555784d13da5d1874e51304711570769c4f2b9b'
40+
- name: Test style
41+
run: make test-style
2942

3043
build:
3144
name: build
3245
runs-on: ubuntu-latest
3346
strategy:
3447
matrix:
35-
go: [1.16]
48+
go: [1.18]
3649
fix-version:
3750
- FIX_TEST=
3851
- FIX_TEST=fix40

.golangci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
run:
2+
timeout: 10m
3+
skip-dirs:
4+
- gen
5+
- vendor
6+
7+
linters:
8+
disable-all: true
9+
enable:
10+
- deadcode
11+
- dupl
12+
- gofmt
13+
- goimports
14+
- gosimple
15+
- govet
16+
- ineffassign
17+
- misspell
18+
- revive
19+
- unused
20+
- varcheck
21+
- staticcheck
22+
23+
linters-settings:
24+
gofmt:
25+
simplify: true
26+
goimports:
27+
local-prefixes: github.com/quickfixgo/quickfix
28+
dupl:
29+
threshold: 400

Makefile

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
GOBIN = $(shell go env GOBIN)
2+
ifeq ($(GOBIN),)
3+
GOBIN = $(shell go env GOPATH)/bin
4+
endif
5+
GOX = $(GOBIN)/gox
6+
GOIMPORTS = $(GOBIN)/goimports
7+
ARCH = $(shell uname -p)
8+
9+
# ------------------------------------------------------------------------------
10+
# dependencies
11+
12+
# If go install is run from inside the project directory it will add the
13+
# dependencies to the go.mod file. To avoid that we change to a directory
14+
# without a go.mod file when downloading the following dependencies
15+
16+
$(GOX):
17+
(cd /; GO111MODULE=on go install github.com/mitchellh/gox@latest)
18+
19+
$(GOIMPORTS):
20+
(cd /; GO111MODULE=on go install golang.org/x/tools/cmd/goimports@latest)
21+
22+
# ------------------------------------------------------------------------------
23+
124
all: vet test
225

326
clean:
@@ -10,16 +33,19 @@ generate: clean
1033
generate-dist:
1134
cd ..; go run quickfix/cmd/generate-fix/generate-fix.go quickfix/spec/*.xml
1235

36+
test-style:
37+
GO111MODULE=on golangci-lint run
38+
39+
.PHONY: format
40+
format: $(GOIMPORTS)
41+
GO111MODULE=on go list -f '{{.Dir}}' ./... | xargs $(GOIMPORTS) -w -local github.com/quickfixgo/quickfix
42+
1343
fmt:
1444
go fmt `go list ./... | grep -v quickfix/gen`
1545

1646
vet:
1747
go vet `go list ./... | grep -v quickfix/gen`
1848

19-
lint:
20-
go get github.com/golang/lint/golint
21-
golint .
22-
2349
test:
2450
MONGODB_TEST_CXN=localhost go test -v -cover . ./datadictionary ./internal
2551

acceptor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"sync"
1212

1313
proxyproto "github.com/armon/go-proxyproto"
14+
1415
"github.com/quickfixgo/quickfix/config"
1516
)
1617

@@ -130,7 +131,7 @@ func (a *Acceptor) Stop() {
130131
a.sessionGroup.Wait()
131132
}
132133

133-
//Get remote IP address for a given session.
134+
// RemoteAddr gets remote IP address for a given session.
134135
func (a *Acceptor) RemoteAddr(sessionID SessionID) (net.Addr, bool) {
135136
addr, ok := a.sessionAddr.Load(sessionID)
136137
if !ok || addr == nil {

datadictionary/component_type_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package datadictionary_test
33
import (
44
"testing"
55

6-
"github.com/quickfixgo/quickfix/datadictionary"
76
"github.com/stretchr/testify/assert"
7+
8+
"github.com/quickfixgo/quickfix/datadictionary"
89
)
910

1011
func TestNewComponentType(t *testing.T) {

datadictionary/field_def_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package datadictionary_test
33
import (
44
"testing"
55

6-
"github.com/quickfixgo/quickfix/datadictionary"
76
"github.com/stretchr/testify/assert"
7+
8+
"github.com/quickfixgo/quickfix/datadictionary"
89
)
910

1011
func TestNewFieldDef(t *testing.T) {

datadictionary/field_type_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package datadictionary_test
33
import (
44
"testing"
55

6-
"github.com/quickfixgo/quickfix/datadictionary"
76
"github.com/stretchr/testify/assert"
7+
8+
"github.com/quickfixgo/quickfix/datadictionary"
89
)
910

1011
func TestNewFieldType(t *testing.T) {

0 commit comments

Comments
 (0)