File tree Expand file tree Collapse file tree 3 files changed +22
-12
lines changed
Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Original file line number Diff line number Diff line change 1919 fail-fast : false
2020 matrix :
2121 os : ["windows-2022", "ubuntu-24.04", "macos-14"]
22- go : ["1.24.x", "1.25.x"]
22+ go : ["1.23.x", "1. 24.x", "1.25.x"]
2323 runs-on : ${{ matrix.os }}
2424 steps :
2525 - uses : actions/checkout@v6
3232
3333 - run : go version
3434
35- - name : Test Styling (gofmt)
36- run : gofmt -l . && echo '✔ Your code looks good.'
37-
38- # yamllint disable rule:line-length
39- - name : Test Styling (analysis/modernize) Analyzer modernize
40- if : ${{ ! startsWith(matrix.go, '1.22') }}
41- run : go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -test ./...
42- # yamllint enable rule:line-length
35+ - name : Test Styling (gofmt & modernize)
36+ run : make test/styling
4337
4438 - name : Lint (go vet)
4539 run : go vet -v ./...
Original file line number Diff line number Diff line change 1919 fail-fast : false
2020 matrix :
2121 os : ["windows-2022", "ubuntu-24.04", "macos-14"]
22- go : ["1.24.x", "1.25.x"]
22+ go : ["1.23.x", "1. 24.x", "1.25.x"]
2323 runs-on : ${{ matrix.os }}
2424 steps :
2525 - uses : actions/checkout@v6
Original file line number Diff line number Diff line change @@ -39,6 +39,22 @@ PKG_LIST=$(go list ./... | grep -v /vendor/ | tr '\n' ' '| xargs echo -n)
3939BUILDKIT_PROGRESS =plain
4040CGO_ENABLED =0
4141
42+ # Modernize tool versioning
43+ # Go 1.25 requires gopls v0.21.0+
44+ # Go 1.24 and below should use gopls v0.20.0
45+ GO_VERSION := $(shell go version | cut -d' ' -f3 | sed 's/go//')
46+ MODERNIZE_VER := v0.20.0
47+
48+ # Check if Go version is 1.25 or higher
49+ IS_GO_125 := $(shell echo "$(GO_VERSION ) " | awk -F. '{if ($$1 > 1 || ($$1 == 1 && $$2 >= 25) ) print 1; else print 0}')
50+
51+ ifeq ($(IS_GO_125 ) ,1)
52+ MODERNIZE_VER := latest
53+ endif
54+
55+ # Use GOTOOLCHAIN=auto to ensure the required toolchain is available if needed
56+ MODERNIZE_CMD := GOTOOLCHAIN=auto $(GO ) run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@$(MODERNIZE_VER )
57+
4258.MAIN : test/coverage
4359.PHONY : all clean coverage dependencies help list test
4460.EXPORT_ALL_VARIABLES : # (2)
@@ -82,10 +98,10 @@ test/static: dependencies
8298
8399test/styling : dependencies
84100 gofmt -l . && echo ' ✔ Your code looks good.'
85- $(GO ) run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -test ./...
101+ $(MODERNIZE_CMD ) -test ./...
86102
87103format :
88- $(GO ) run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix ./...
104+ $(MODERNIZE_CMD ) -fix ./...
89105
90106coverage.out : env dependencies
91107 $(GOTEST ) -v -covermode=atomic -coverprofile=" coverage.out" ./exercises/...
You can’t perform that action at this time.
0 commit comments