Skip to content

Commit

Permalink
Support go1.13 (#670)
Browse files Browse the repository at this point in the history
Setup Travis CI to run on go 1.12 and 1.13.
Update info about go versions in README.
Rebuild go.mod,go.sum on go1.13.
  • Loading branch information
jirfag committed Sep 9, 2019
1 parent a8f2c27 commit 6163a8a
Show file tree
Hide file tree
Showing 49 changed files with 192 additions and 6,781 deletions.
5 changes: 4 additions & 1 deletion .golangci.example.yml
Expand Up @@ -123,7 +123,10 @@ linters-settings:
list-type: blacklist
include-go-root: false
packages:
- github.com/davecgh/go-spew/spew
- github.com/sirupsen/logrus
packages-with-error-messages:
# specify an error message to output when a blacklisted package is used
github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
Expand Down
10 changes: 6 additions & 4 deletions .golangci.yml
Expand Up @@ -41,19 +41,16 @@ linters-settings:
disabled-checks:
- wrapperFunc
- dupImport # https://github.com/go-critic/go-critic/issues/845
funlen:
lines: 70

linters:
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dupl
- errcheck
- funlen
# - funlen - TODO: enable it when golangci.com will support it.
- gochecknoinits
- goconst
- gocritic
Expand All @@ -79,6 +76,11 @@ linters:
- unused
- varcheck

# don't enable:
# - depguard - until https://github.com/OpenPeeDeeP/depguard/issues/7 gets fixed
# - maligned,prealloc
# - gochecknoglobals

run:
skip-dirs:
- test/testdata_etc
Expand Down
11 changes: 7 additions & 4 deletions .travis.yml
@@ -1,18 +1,21 @@
language: go
go:
- 1.11.x
- 1.12.x
- 1.13.x

env:
global:
- NODE_VERSION=10.15.0

before_script:
- go get github.com/valyala/quicktemplate # for tests
- go get github.com/pkg/errors # for tests
# use GO111MODULE=off otherwise libs can't be updates inside vendor/
- GO111MODULE=off go get github.com/valyala/quicktemplate # for tests
- GO111MODULE=off go get github.com/pkg/errors # for tests
- nvm install "${NODE_VERSION}"

script: make check_generated test
script:
- time make fast_check_generated
- time make test

branches:
only: # speed up CI: don't build pull requests twice
Expand Down
31 changes: 23 additions & 8 deletions Makefile
Expand Up @@ -11,11 +11,15 @@ clean:

# Test

# until https://github.com/OpenPeeDeeP/depguard/issues/7 fixed
test: export GO111MODULE = off
test: export GOLANGCI_LINT_INSTALLED = true

test: build
GL_TEST_RUN=1 ./golangci-lint run -v
GL_TEST_RUN=1 ./golangci-lint run --fast --no-config -v --skip-dirs 'test/testdata_etc,pkg/golinters/goanalysis/(checker|passes)'
GL_TEST_RUN=1 ./golangci-lint run --no-config -v --skip-dirs 'test/testdata_etc,pkg/golinters/goanalysis/(checker|passes)'
GL_TEST_RUN=1 go test -v ./...
GL_TEST_RUN=1 time ./golangci-lint run -v
GL_TEST_RUN=1 time ./golangci-lint run --fast --no-config -v --skip-dirs 'test/testdata_etc,pkg/golinters/goanalysis/(checker|passes)'
GL_TEST_RUN=1 time ./golangci-lint run --no-config -v --skip-dirs 'test/testdata_etc,pkg/golinters/goanalysis/(checker|passes)'
GL_TEST_RUN=1 time go test -v ./...

.PHONY: test

Expand All @@ -30,8 +34,9 @@ test_linters:

# Maintenance

generate: README.md install.sh pkg/logutils/log_mock.go vendor
generate_svg: docs/demo.svg
generate: README.md docs/demo.svg install.sh pkg/logutils/log_mock.go vendor
fast_generate: README.md vendor

maintainer-clean: clean
rm -f docs/demo.svg README.md install.sh pkg/logutils/log_mock.go
rm -rf vendor
Expand All @@ -40,9 +45,17 @@ maintainer-clean: clean
check_generated:
$(MAKE) --always-make generate
git checkout -- go.mod go.sum # can differ between go1.11 and go1.12
git checkout -- vendor/modules.txt # can differ between go1.12 and go1.13
git diff --exit-code # check no changes
.PHONY: check_generated

fast_check_generated:
$(MAKE) --always-make fast_generate
git checkout -- go.mod go.sum # can differ between go1.11 and go1.12
git checkout -- vendor/modules.txt # can differ between go1.12 and go1.13
git diff --exit-code # check no changes
.PHONY: fast_check_generated

release:
rm -rf dist
curl -sL https://git.io/goreleaser | bash
Expand All @@ -65,7 +78,8 @@ tools/go.mod:
cd tools && GO111MODULE=on go mod init local-tools

tools/godownloader: Makefile tools/go.mod
cd tools && GOBIN=$(CURDIR)/tools GO111MODULE=on go get github.com/goreleaser/godownloader@3b90d248ba30307915288f08ab3f2fc2d9f6710c
# https://github.com/goreleaser/godownloader/issues/133
cd tools && GOBIN=$(CURDIR)/tools GO111MODULE=off go get github.com/goreleaser/godownloader

tools/svg-term:
@mkdir -p tools
Expand All @@ -79,7 +93,8 @@ tools/Dracula.itermcolors:
docs/demo.svg: tools/svg-term tools/Dracula.itermcolors
PATH=$(CURDIR)/tools:$${PATH} svg-term --cast=183662 --out docs/demo.svg --window --width 110 --height 30 --from 2000 --to 20000 --profile ./tools/Dracula.itermcolors --term iterm2

install.sh: tools/godownloader .goreleaser.yml
install.sh:
# dependencies: tools/godownloader .goreleaser.yml
# TODO: use when Windows installation will be fixed in the upstream
#PATH=$(CURDIR)/tools:$${PATH} tools/godownloader .goreleaser.yml | sed '/DO NOT EDIT/s/ on [0-9TZ:-]*//' > $@

Expand Down
38 changes: 23 additions & 15 deletions README.md
Expand Up @@ -52,8 +52,9 @@ use `--enable-all` and a new linter is added or even without `--enable-all`: whe
It's highly recommended to install a fixed version of golangci-lint.
Releases are available on the [releases page](https://github.com/golangci/golangci-lint/releases).

The recommended way to install golangci-lint (replace `vX.Y.Z` with the latest
version from the [releases page](https://github.com/golangci/golangci-lint/releases)):
Latest version: ![GitHub release](https://img.shields.io/github/release/golangci/golangci-lint.svg)

Here is the recommended way to install golangci-lint (replace `vX.Y.Z` with the latest version):

```bash
# binary will be $(go env GOPATH)/bin/golangci-lint
Expand Down Expand Up @@ -676,7 +677,10 @@ linters-settings:
list-type: blacklist
include-go-root: false
packages:
- github.com/davecgh/go-spew/spew
- github.com/sirupsen/logrus
packages-with-error-messages:
# specify an error message to output when a blacklisted package is used
github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
Expand Down Expand Up @@ -861,19 +865,16 @@ linters-settings:
disabled-checks:
- wrapperFunc
- dupImport # https://github.com/go-critic/go-critic/issues/845
funlen:
lines: 70
linters:
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dupl
- errcheck
- funlen
# - funlen - TODO: enable it when golangci.com will support it.
- gochecknoinits
- goconst
- gocritic
Expand All @@ -899,6 +900,11 @@ linters:
- unused
- varcheck
# don't enable:
# - depguard - until https://github.com/OpenPeeDeeP/depguard/issues/7 gets fixed
# - maligned,prealloc
# - gochecknoglobals
run:
skip-dirs:
- test/testdata_etc
Expand Down Expand Up @@ -947,13 +953,13 @@ To exclude issues for the block of code use this directive on the beginning of a
```go
//nolint
func allIssuesInThisFunctionAreExcluded() *string {
// ...
// ...
}
//nolint:govet
var (
a int
b int
a int
b int
)
```
Expand All @@ -969,7 +975,7 @@ You may add a comment explaining or justifying why `//nolint` is being used on t
```go
//nolint:gocyclo // This legacy function is complex but the team too busy to simplify it
func someLegacyFunction() *string {
// ...
// ...
}
```
Expand Down Expand Up @@ -1002,13 +1008,15 @@ We don't recommend vendoring `golangci-lint` in your repo: you will get troubles
No, you don't need to do it anymore.
**Which go versions are supported**
Short answer: go 1.11 and newer are oficially supported.
Short answer: go 1.12 and newer are oficially supported.
Long answer:
1. go < 1.9 isn't supported
2. go 1.9 is supported by golangci-lint <= v1.10.2
3. go 1.10 is officially supported by golangci-lint <= 1.15.0.
4. go1.11 and go1.12 are officially supported by the latest version of golangci-lint.
2. go1.9 is officially supported by golangci-lint <= v1.10.2
3. go1.10 is officially supported by golangci-lint <= 1.15.0.
4. go1.11 is officially supported by golangci-lint <= 1.17.1.
5. go1.12 and go1.13 are officially supported by the latest version of golangci-lint (>= 1.18.0).
**`golangci-lint` doesn't work**
Expand Down
23 changes: 13 additions & 10 deletions README.tmpl.md
Expand Up @@ -52,8 +52,9 @@ use `--enable-all` and a new linter is added or even without `--enable-all`: whe
It's highly recommended to install a fixed version of golangci-lint.
Releases are available on the [releases page](https://github.com/golangci/golangci-lint/releases).

The recommended way to install golangci-lint (replace `vX.Y.Z` with the latest
version from the [releases page](https://github.com/golangci/golangci-lint/releases)):
Latest version: ![GitHub release](https://img.shields.io/github/release/golangci/golangci-lint.svg)

Here is the recommended way to install golangci-lint (replace `vX.Y.Z` with the latest version):

```bash
# binary will be $(go env GOPATH)/bin/golangci-lint
Expand Down Expand Up @@ -455,13 +456,13 @@ To exclude issues for the block of code use this directive on the beginning of a
```go
//nolint
func allIssuesInThisFunctionAreExcluded() *string {
// ...
// ...
}

//nolint:govet
var (
a int
b int
a int
b int
)
```

Expand All @@ -477,7 +478,7 @@ You may add a comment explaining or justifying why `//nolint` is being used on t
```go
//nolint:gocyclo // This legacy function is complex but the team too busy to simplify it
func someLegacyFunction() *string {
// ...
// ...
}
```

Expand Down Expand Up @@ -510,13 +511,15 @@ We don't recommend vendoring `golangci-lint` in your repo: you will get troubles
No, you don't need to do it anymore.

**Which go versions are supported**
Short answer: go 1.11 and newer are oficially supported.
Short answer: go 1.12 and newer are oficially supported.

Long answer:

1. go < 1.9 isn't supported
2. go 1.9 is supported by golangci-lint <= v1.10.2
3. go 1.10 is officially supported by golangci-lint <= 1.15.0.
4. go1.11 and go1.12 are officially supported by the latest version of golangci-lint.
2. go1.9 is officially supported by golangci-lint <= v1.10.2
3. go1.10 is officially supported by golangci-lint <= 1.15.0.
4. go1.11 is officially supported by golangci-lint <= 1.17.1.
5. go1.12 and go1.13 are officially supported by the latest version of golangci-lint (>= 1.18.0).

**`golangci-lint` doesn't work**

Expand Down
18 changes: 11 additions & 7 deletions go.mod
Expand Up @@ -14,15 +14,15 @@ require (
github.com/golang/mock v1.0.0
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a
github.com/golangci/errcheck v0.0.0-20181003203344-ef45e06d44b6
github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6
github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613
github.com/golangci/go-tools v0.0.0-20190318055746-e32c54105b7c
github.com/golangci/goconst v0.0.0-20180610141641-041c5f2b40f3
github.com/golangci/gocyclo v0.0.0-20180528134321-2becd97e67ee
github.com/golangci/gofmt v0.0.0-20181222123516-0b8337e80d98
github.com/golangci/gosec v0.0.0-20180901114220-66fb7fc33547
github.com/golangci/gosec v0.0.0-20190211064107-66fb7fc33547
github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc
github.com/golangci/lint-1 v0.0.0-20180610141402-ee948d087217
github.com/golangci/lint-1 v0.0.0-20190420132249-ee948d087217
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca
github.com/golangci/misspell v0.0.0-20180809174111-950f5d19e770
github.com/golangci/prealloc v0.0.0-20180630174525-215b22d4de21
Expand Down Expand Up @@ -51,7 +51,7 @@ require (
github.com/spf13/pflag v1.0.1
github.com/spf13/viper v1.0.2
github.com/stretchr/testify v1.2.2
github.com/timakin/bodyclose v0.0.0-00010101000000-87058b9bfcec
github.com/timakin/bodyclose v0.0.0-20190721030226-87058b9bfcec
github.com/ultraware/funlen v0.0.1
github.com/valyala/quicktemplate v1.1.1
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a // indirect
Expand All @@ -62,8 +62,12 @@ require (
gopkg.in/yaml.v2 v2.2.1
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
mvdan.cc/unparam v0.0.0-20190124213536-fbb59629db34
mvdan.cc/unparam v0.0.0-20190209190245-fbb59629db34
)

// https://github.com/golang/tools/pull/139
replace golang.org/x/tools => github.com/golangci/tools v0.0.0-20190713050349-979bdb7f8cc8
replace (
// https://github.com/ultraware/funlen/pull/1
github.com/ultraware/funlen => github.com/golangci/funlen v0.0.0-20190909161642-5e59b9546114
// https://github.com/golang/tools/pull/139
golang.org/x/tools => github.com/golangci/tools v0.0.0-20190909104219-979bdb7f8cc8
)

0 comments on commit 6163a8a

Please sign in to comment.