Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go1.19 support #3037

Merged
merged 7 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
go-version: 1.18
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
lafriks marked this conversation as resolved.
Show resolved Hide resolved
go-version: 1.19

- name: Update GitHub action config
run: make assets/github-action-config.json
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
go-version: 1.18
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
go-version: 1.19
- name: Run go list
run: go list -json -m all > go.list
- name: Nancy
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

env:
GO_VERSION: 1.18
GO_VERSION: 1.19

jobs:
# Check if there any dirty change for go mod tidy
Expand All @@ -16,7 +16,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -34,8 +34,9 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
go-version: ${{ env.GO_VERSION }}
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
# go-version: ${{ env.GO_VERSION }} # todo(ldez) uncomment after the next release v1.48.0
go-version: 1.18
- name: lint
uses: golangci/golangci-lint-action@v3.2.0
with:
Expand All @@ -52,7 +53,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
go-version: ${{ env.GO_VERSION }} # test only the latest go version to speed up CI
- name: Run tests
run: make.exe test
Expand All @@ -66,7 +67,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
go-version: ${{ env.GO_VERSION }} # test only the latest go version to speed up CI
- name: Run tests
run: make test
Expand All @@ -77,14 +78,14 @@ jobs:
strategy:
matrix:
golang:
- 1.17
- 1.18
- 1.19
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
go-version: ${{ matrix.golang }}
- uses: actions/cache@v3
with:
Expand All @@ -108,7 +109,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
go-version: ${{ env.GO_VERSION }}
- name: Check generated files are up to date
run: make fast_check_generated
8 changes: 4 additions & 4 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
go-version: 1.18
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
go-version: 1.19
- name: Unshallow
run: git fetch --prune --unshallow

Expand All @@ -41,8 +41,8 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
go-version: 1.18
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc.1).
go-version: 1.19

- name: Unshallow
run: git fetch --prune --unshallow
Expand Down
6 changes: 3 additions & 3 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ run:
allow-parallel-runners: false

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


# output configuration options
Expand Down
4 changes: 2 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# stage 1 building the code
FROM golang:1.18 as builder
FROM golang:1.19 as builder

ARG VERSION
ARG SHORT_COMMIT
Expand All @@ -10,7 +10,7 @@ WORKDIR /golangci
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

# stage 2
FROM golang:1.18
FROM golang:1.19
# don't place it into $GOPATH/bin because Drone mounts $GOPATH as volume
COPY --from=builder /golangci/golangci-lint /usr/bin/
CMD ["golangci-lint"]
4 changes: 2 additions & 2 deletions build/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# stage 1 building the code
FROM golang:1.18-alpine as builder
FROM golang:1.19-alpine as builder

ARG VERSION
ARG SHORT_COMMIT
Expand All @@ -15,7 +15,7 @@ RUN apk --no-cache add gcc musl-dev git mercurial
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

# stage 2
FROM golang:1.18-alpine
FROM golang:1.19-alpine
# gcc is required to support cgo;
# git and mercurial are needed most times for go get`, etc.
# See https://github.com/docker-library/golang/issues/80
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/golangci/golangci-lint

go 1.18
go 1.19

require (
4d63.com/gochecknoglobals v0.1.0
Expand Down
10 changes: 9 additions & 1 deletion pkg/golinters/goanalysis/runner_loadingpackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,15 @@ func (lp *loadingPackage) loadFromSource(loadMode LoadMode) error {

pkg.IllTyped = true

pkg.TypesInfo = newTypesInfo()
pkg.TypesInfo = &types.Info{
Types: make(map[ast.Expr]types.TypeAndValue),
Instances: make(map[*ast.Ident]types.Instance),
Defs: make(map[*ast.Ident]types.Object),
Uses: make(map[*ast.Ident]types.Object),
Implicits: make(map[ast.Node]types.Object),
Scopes: make(map[ast.Node]*types.Scope),
Selections: make(map[*ast.SelectorExpr]*types.Selection),
}

importer := func(path string) (*types.Package, error) {
if path == unsafePkgName {
Expand Down
21 changes: 0 additions & 21 deletions pkg/golinters/goanalysis/runner_loadingpackage_ti.go

This file was deleted.

20 changes: 0 additions & 20 deletions pkg/golinters/goanalysis/runner_loadingpackage_ti_go117.go

This file was deleted.

1 change: 1 addition & 0 deletions pkg/golinters/staticcheck_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func staticCheckConfig(settings *config.StaticCheckSettings) *scconfig.Config {
}

// https://github.com/dominikh/go-tools/blob/9bf17c0388a65710524ba04c2d821469e639fdc2/lintcmd/lint.go#L437-L477
//
//nolint:gocritic // Keep the original source code.
func filterAnalyzerNames(analyzers []string, checks []string) map[string]bool {
allowedChecks := map[string]bool{}
Expand Down
4 changes: 2 additions & 2 deletions pkg/lint/linter/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ type Noop struct {
}

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

Expand Down
13 changes: 4 additions & 9 deletions test/linters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,10 @@ func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext
require.Failf(t, "invalid prefix of comment line %s", line)
}

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

after = strings.TrimSpace(after)

switch before {
case "//golangcitest:args":
Expand Down