Skip to content

go1.22 support #4272

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

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Build and deploy documentation
runs-on: ubuntu-latest
env:
GO_VERSION: '1.21'
GO_VERSION: '1.22'
NODE_VERSION: '20.x'
CGO_ENABLED: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# ex:
# - 1.18beta1 -> 1.18.0-beta.1
# - 1.18rc1 -> 1.18.0-rc.1
go-version: '1.21'
go-version: '1.22'

- name: Update GitHub action config
run: make assets/github-action-config.json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Build documentation
runs-on: ubuntu-latest
env:
GO_VERSION: '1.21'
GO_VERSION: '1.22'
NODE_VERSION: '20.x'
CGO_ENABLED: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# ex:
# - 1.18beta1 -> 1.18.0-beta.1
# - 1.18rc1 -> 1.18.0-rc.1
go-version: '1.21'
go-version: '1.22'
- name: Run go list
run: go list -json -m all > go.list
- name: Nancy
Expand Down
8 changes: 5 additions & 3 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.21'
GO_VERSION: '1.22'

jobs:
# Check if there is any dirty change for go mod tidy
Expand Down Expand Up @@ -42,7 +42,9 @@ jobs:
# ex:
# - 1.18beta1 -> 1.18.0-beta.1
# - 1.18rc1 -> 1.18.0-rc.1
go-version: ${{ env.GO_VERSION }}
# TODO(ldez) must be changed after the first release of golangci-lint with go1.22
# go-version: ${{ env.GO_VERSION }}
go-version: '1.21'
- name: lint
uses: golangci/[email protected]
with:
Expand Down Expand Up @@ -89,8 +91,8 @@ jobs:
strategy:
matrix:
golang:
- '1.20'
- '1.21'
- '1.22'
steps:
- uses: actions/checkout@v4
- name: Install Go
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
# ex:
# - 1.18beta1 -> 1.18.0-beta.1
# - 1.18rc1 -> 1.18.0-rc.1
go-version: '1.21'
go-version: '1.22'
- name: Unshallow
run: git fetch --prune --unshallow

Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
# ex:
# - 1.18beta1 -> 1.18.0-beta.1
# - 1.18rc1 -> 1.18.0-rc.1
go-version: '1.21'
go-version: '1.22'

- name: Unshallow
run: git fetch --prune --unshallow
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.21 as builder
FROM golang:1.22 as builder

ARG VERSION
ARG SHORT_COMMIT
Expand All @@ -12,7 +12,7 @@ RUN APP_VERSION=${VERSION#v} \
go build -trimpath -ldflags "-s -w -X main.version=$APP_VERSION -X main.commit=$SHORT_COMMIT -X main.date=$DATE" -o golangci-lint ./cmd/golangci-lint/main.go

# stage 2
FROM golang:1.21
FROM golang:1.22
# related to https://github.com/golangci/golangci-lint/issues/3107
ENV GOROOT /usr/local/go
# Set all directories as safe
Expand Down
4 changes: 2 additions & 2 deletions build/alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# stage 1 building the code
FROM golang:1.21-alpine as builder
FROM golang:1.22-alpine as builder

ARG VERSION
ARG SHORT_COMMIT
Expand All @@ -17,7 +17,7 @@ RUN APP_VERSION=${VERSION#v} \
go build -trimpath -ldflags "-s -w -X main.version=$APP_VERSION -X main.commit=$SHORT_COMMIT -X main.date=$DATE" -o golangci-lint ./cmd/golangci-lint/main.go

# stage 2
FROM golang:1.21-alpine
FROM golang:1.22-alpine
# related to https://github.com/golangci/golangci-lint/issues/3107
ENV GOROOT /usr/local/go
# gcc is required to support cgo;
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.20
go 1.21

require (
4d63.com/gocheckcompilerdirectives v1.2.1
Expand Down
18 changes: 18 additions & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ type Version struct {
Debug bool `mapstructure:"debug"`
}

func IsGreaterThanOrEqualGo121(v string) bool {
func IsGreaterThanOrEqualGo122(v string) bool {
v1, err := hcversion.NewVersion(strings.TrimPrefix(v, "go"))
if err != nil {
return false
}

limit, err := hcversion.NewVersion("1.21")
limit, err := hcversion.NewVersion("1.22")
if err != nil {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"

"github.com/go-viper/mapstructure/v2"
"github.com/mitchellh/go-homedir"
"github.com/spf13/viper"
"golang.org/x/exp/slices"

"github.com/golangci/golangci-lint/pkg/exitcodes"
"github.com/golangci/golangci-lint/pkg/fsutils"
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/govet_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package golinters

import (
"slices"
"testing"

"golang.org/x/exp/slices"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/asmdecl"
"golang.org/x/tools/go/analysis/passes/assign"
Expand Down
2 changes: 1 addition & 1 deletion pkg/lint/linter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (lc *Config) Name() string {
}

func (lc *Config) WithNoopFallback(cfg *config.Config) *Config {
if cfg != nil && config.IsGreaterThanOrEqualGo121(cfg.Run.Go) {
if cfg != nil && config.IsGreaterThanOrEqualGo122(cfg.Run.Go) {
lc.Linter = &Noop{
name: lc.Linter.Name(),
desc: lc.Linter.Desc(),
Expand Down
3 changes: 1 addition & 2 deletions test/enabled_linters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package test

import (
"fmt"
"slices"
"sort"
"strings"
"testing"

"golang.org/x/exp/slices"

"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
"github.com/golangci/golangci-lint/test/testshared"
)
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/zerologlint/zerologlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package zerologlint

import (
"fmt"
"slices"

"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"golang.org/x/exp/slices"
)

func expectWarnings() {
Expand Down