Skip to content

Commit 1557692

Browse files
authored
feat: go1.19 support (#3037)
1 parent 6313fa9 commit 1557692

14 files changed

+62
-78
lines changed

.github/workflows/post-release.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ jobs:
1414
- name: Install Go
1515
uses: actions/setup-go@v3
1616
with:
17-
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
18-
go-version: 1.18
17+
# Keep the following comment to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
18+
# https://github.com/actions/setup-go#supported-version-syntax
19+
# stable: 'false'
20+
go-version: 1.19
1921

2022
- name: Update GitHub action config
2123
run: make assets/github-action-config.json

.github/workflows/pr-extra.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ jobs:
1313
- uses: actions/checkout@v3
1414
- uses: actions/setup-go@v3
1515
with:
16-
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
17-
go-version: 1.18
16+
# Keep the following comment to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
17+
# https://github.com/actions/setup-go#supported-version-syntax
18+
# stable: 'false'
19+
go-version: 1.19
1820
- name: Run go list
1921
run: go list -json -m all > go.list
2022
- name: Nancy

.github/workflows/pr.yml

+22-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pull_request:
77

88
env:
9-
GO_VERSION: 1.18
9+
GO_VERSION: 1.19
1010

1111
jobs:
1212
# Check if there any dirty change for go mod tidy
@@ -16,7 +16,9 @@ jobs:
1616
- name: Install Go
1717
uses: actions/setup-go@v3
1818
with:
19-
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
19+
# Keep the following comment to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
20+
# https://github.com/actions/setup-go#supported-version-syntax
21+
# stable: 'false'
2022
go-version: ${{ env.GO_VERSION }}
2123
- name: Checkout code
2224
uses: actions/checkout@v3
@@ -34,8 +36,11 @@ jobs:
3436
- name: Install Go
3537
uses: actions/setup-go@v3
3638
with:
37-
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
38-
go-version: ${{ env.GO_VERSION }}
39+
# Keep the following comment to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
40+
# https://github.com/actions/setup-go#supported-version-syntax
41+
# stable: 'false'
42+
# go-version: ${{ env.GO_VERSION }} # todo(ldez) uncomment after the next release v1.48.0
43+
go-version: 1.18
3944
- name: lint
4045
uses: golangci/[email protected]
4146
with:
@@ -52,7 +57,9 @@ jobs:
5257
- name: Install Go
5358
uses: actions/setup-go@v3
5459
with:
55-
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
60+
# Keep the following comment to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
61+
# https://github.com/actions/setup-go#supported-version-syntax
62+
# stable: 'false'
5663
go-version: ${{ env.GO_VERSION }} # test only the latest go version to speed up CI
5764
- name: Run tests
5865
run: make.exe test
@@ -66,7 +73,9 @@ jobs:
6673
- name: Install Go
6774
uses: actions/setup-go@v3
6875
with:
69-
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
76+
# Keep the following comment to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
77+
# https://github.com/actions/setup-go#supported-version-syntax
78+
# stable: 'false'
7079
go-version: ${{ env.GO_VERSION }} # test only the latest go version to speed up CI
7180
- name: Run tests
7281
run: make test
@@ -77,14 +86,16 @@ jobs:
7786
strategy:
7887
matrix:
7988
golang:
80-
- 1.17
8189
- 1.18
90+
- 1.19
8291
steps:
8392
- uses: actions/checkout@v3
8493
- name: Install Go
8594
uses: actions/setup-go@v3
8695
with:
87-
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
96+
# Keep the following comment to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
97+
# https://github.com/actions/setup-go#supported-version-syntax
98+
# stable: 'false'
8899
go-version: ${{ matrix.golang }}
89100
- uses: actions/cache@v3
90101
with:
@@ -108,7 +119,9 @@ jobs:
108119
- name: Install Go
109120
uses: actions/setup-go@v3
110121
with:
111-
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
122+
# Keep the following comment to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
123+
# https://github.com/actions/setup-go#supported-version-syntax
124+
# stable: 'false'
112125
go-version: ${{ env.GO_VERSION }}
113126
- name: Check generated files are up to date
114127
run: make fast_check_generated

.github/workflows/tag.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ jobs:
1414
- name: Install Go
1515
uses: actions/setup-go@v3
1616
with:
17-
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
18-
go-version: 1.18
17+
# Keep the following comment to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
18+
# https://github.com/actions/setup-go#supported-version-syntax
19+
# stable: 'false'
20+
go-version: 1.19
1921
- name: Unshallow
2022
run: git fetch --prune --unshallow
2123

@@ -41,8 +43,10 @@ jobs:
4143
- name: Install Go
4244
uses: actions/setup-go@v3
4345
with:
44-
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
45-
go-version: 1.18
46+
# Keep the following comment to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
47+
# https://github.com/actions/setup-go#supported-version-syntax
48+
# stable: 'false'
49+
go-version: 1.19
4650

4751
- name: Unshallow
4852
run: git fetch --prune --unshallow

.golangci.reference.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ run:
6868
allow-parallel-runners: false
6969

7070
# Define the Go version limit.
71-
# Mainly related to generics support in go1.18.
72-
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17
73-
go: '1.18'
71+
# Mainly related to generics support since go1.18.
72+
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.18
73+
go: '1.19'
7474

7575

7676
# output configuration options

build/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# stage 1 building the code
2-
FROM golang:1.18 as builder
2+
FROM golang:1.19 as builder
33

44
ARG VERSION
55
ARG SHORT_COMMIT
@@ -10,7 +10,7 @@ WORKDIR /golangci
1010
RUN CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=$VERSION -X main.commit=$SHORT_COMMIT -X main.date=$DATE" -o golangci-lint ./cmd/golangci-lint/main.go
1111

1212
# stage 2
13-
FROM golang:1.18
13+
FROM golang:1.19
1414
# don't place it into $GOPATH/bin because Drone mounts $GOPATH as volume
1515
COPY --from=builder /golangci/golangci-lint /usr/bin/
1616
CMD ["golangci-lint"]

build/Dockerfile.alpine

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# stage 1 building the code
2-
FROM golang:1.18-alpine as builder
2+
FROM golang:1.19-alpine as builder
33

44
ARG VERSION
55
ARG SHORT_COMMIT
@@ -15,7 +15,7 @@ RUN apk --no-cache add gcc musl-dev git mercurial
1515
RUN CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=$VERSION -X main.commit=$SHORT_COMMIT -X main.date=$DATE" -o golangci-lint ./cmd/golangci-lint/main.go
1616

1717
# stage 2
18-
FROM golang:1.18-alpine
18+
FROM golang:1.19-alpine
1919
# gcc is required to support cgo;
2020
# git and mercurial are needed most times for go get`, etc.
2121
# See https://github.com/docker-library/golang/issues/80

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/golangci/golangci-lint
22

3-
go 1.18
3+
go 1.19
44

55
require (
66
4d63.com/gochecknoglobals v0.1.0

pkg/golinters/goanalysis/runner_loadingpackage.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,15 @@ func (lp *loadingPackage) loadFromSource(loadMode LoadMode) error {
121121

122122
pkg.IllTyped = true
123123

124-
pkg.TypesInfo = newTypesInfo()
124+
pkg.TypesInfo = &types.Info{
125+
Types: make(map[ast.Expr]types.TypeAndValue),
126+
Instances: make(map[*ast.Ident]types.Instance),
127+
Defs: make(map[*ast.Ident]types.Object),
128+
Uses: make(map[*ast.Ident]types.Object),
129+
Implicits: make(map[ast.Node]types.Object),
130+
Scopes: make(map[ast.Node]*types.Scope),
131+
Selections: make(map[*ast.SelectorExpr]*types.Selection),
132+
}
125133

126134
importer := func(path string) (*types.Package, error) {
127135
if path == unsafePkgName {

pkg/golinters/goanalysis/runner_loadingpackage_ti.go

-21
This file was deleted.

pkg/golinters/goanalysis/runner_loadingpackage_ti_go117.go

-20
This file was deleted.

pkg/golinters/staticcheck_common.go

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func staticCheckConfig(settings *config.StaticCheckSettings) *scconfig.Config {
9898
}
9999

100100
// https://github.com/dominikh/go-tools/blob/9bf17c0388a65710524ba04c2d821469e639fdc2/lintcmd/lint.go#L437-L477
101+
//
101102
//nolint:gocritic // Keep the original source code.
102103
func filterAnalyzerNames(analyzers []string, checks []string) map[string]bool {
103104
allowedChecks := map[string]bool{}

pkg/lint/linter/linter.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ type Noop struct {
2121
}
2222

2323
func (n Noop) Run(_ context.Context, lintCtx *Context) ([]result.Issue, error) {
24-
lintCtx.Log.Warnf("%s is disabled because of go1.18."+
25-
" You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649.", n.name)
24+
lintCtx.Log.Warnf("%s is disabled because of generics."+
25+
" You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649.", n.name)
2626
return nil, nil
2727
}
2828

test/linters_test.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,10 @@ func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext
312312
require.Failf(t, "invalid prefix of comment line %s", line)
313313
}
314314

315-
// TODO(ldez) replace that by strings.Cut when we will drop go1.17
316-
var before string
317-
var after string
318-
if i := strings.Index(line, " "); i >= 0 {
319-
before = line[:i]
320-
after = strings.TrimSpace(line[i+len(" "):])
321-
} else {
322-
require.Failf(t, "invalid prefix of comment line %s", line)
323-
}
315+
before, after, found := strings.Cut(line, " ")
316+
require.Truef(t, found, "invalid prefix of comment line %s", line)
317+
318+
after = strings.TrimSpace(after)
324319

325320
switch before {
326321
case "//golangcitest:args":

0 commit comments

Comments
 (0)