Skip to content

Commit ed0b962

Browse files
authored
Modernize + Go version bump + Pin linter (#5256)
* Upgrade go version in CI. * Add toolchain to pin version. * Add linter/fumpt as pinned version in tools. * Run `go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...`
1 parent 7394ce0 commit ed0b962

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+820
-238
lines changed

.github/workflows/go-cross.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ${{ matrix.os }}
2121
strategy:
2222
matrix:
23-
go-version: [1.23.x]
23+
go-version: [1.25.x]
2424
os: [ubuntu-latest]
2525
steps:
2626
- uses: actions/checkout@v4

.github/workflows/go.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
GO111MODULE: on
2020
strategy:
2121
matrix:
22-
go-version: [1.23.x]
22+
go-version: [1.25.x]
2323
os: [ubuntu-latest, macos-latest, windows-latest]
2424
steps:
2525
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -69,14 +69,11 @@ jobs:
6969
- name: Set up Go
7070
uses: actions/setup-go@v2
7171
with:
72-
go-version: 1.23.x
72+
go-version: 1.24.x
7373

7474
- name: Checkout code
7575
uses: actions/checkout@v2
7676

7777
- name: Test 386
7878
run: GOOS=linux GOARCH=386 go test -short ./...
7979

80-
- name: Staticcheck
81-
# Run with defaults, but allow errors with other formats ST1005
82-
run: go install honnef.co/go/tools/cmd/staticcheck@latest && make lint

.github/workflows/vulncheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Go
1717
uses: actions/setup-go@v5
1818
with:
19-
go-version: 1.23.6
19+
go-version: 1.25.x
2020
- name: Get official govulncheck
2121
run: go install golang.org/x/vuln/cmd/govulncheck@latest
2222
shell: bash

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ TARGET_GOOS ?= $(shell go env GOOS)
88
VERSION ?= $(shell git describe --tags)
99
TAG ?= "minio/mc:$(VERSION)"
1010

11-
GOLANGCI_DIR = .bin/golangci/$(GOLANGCI_VERSION)
12-
GOLANGCI = $(GOLANGCI_DIR)/golangci-lint
11+
GOLANGCI = $(GOPATH)/bin/golangci-lint
1312

1413
all: build
1514

@@ -19,8 +18,7 @@ checks:
1918

2019
getdeps:
2120
@mkdir -p ${GOPATH}/bin
22-
@echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOLANGCI_DIR)
23-
@echo "Installing stringer" && go install -v golang.org/x/tools/cmd/stringer@latest
21+
@echo "Installing tools" && go install tool
2422

2523
crosscompile:
2624
@(env bash $(PWD)/buildscripts/cross-compile.sh)

cmd/admin-bucket-remote-add_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ func TestGetBandwidthInBytes(t *testing.T) {
121121
}
122122
t.Parallel()
123123
for _, tt := range tests {
124-
tt := tt
125124
t.Run(tt.name, func(t *testing.T) {
126125
if got, err := getBandwidthInBytes(tt.args.bandwidthStr); err != nil || got != tt.want {
127126
t.Errorf("getBandwidthInBytes() = %v, want %v", got, tt.want)

cmd/admin-decom-status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func mainAdminDecommissionStatus(ctx *cli.Context) error {
125125
}
126126

127127
dspOrder := []col{colGreen} // Header
128-
for i := 0; i < len(poolStatuses); i++ {
128+
for range poolStatuses {
129129
dspOrder = append(dspOrder, colGrey)
130130
}
131131
var printColors []*color.Color

cmd/admin-replicate-resync-status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func (m *resyncMetricsUI) View() string {
206206
table.SetNoWhiteSpace(true)
207207

208208
var data [][]string
209-
addLine := func(prefix string, value interface{}) {
209+
addLine := func(prefix string, value any) {
210210
data = append(data, []string{
211211
prefix,
212212
whiteStyle.Render(fmt.Sprint(value)),

cmd/admin-replicate-status.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,7 @@ func (i srStatus) String() string {
426426
currDowntime = UTCNow().Sub(m.LastOnline)
427427
}
428428
// normalize because total downtime is calculated at server side at heartbeat interval, may be slightly behind
429-
totalDowntime := m.TotalDowntime
430-
if currDowntime > totalDowntime {
431-
totalDowntime = currDowntime
432-
}
429+
totalDowntime := max(currDowntime, m.TotalDowntime)
433430
var linkStatus string
434431
if m.Online {
435432
linkStatus = healthDot + fmt.Sprintf(" online (total downtime: %s)", timeDurationToHumanizedDuration(totalDowntime).String())

cmd/admin-scanner-status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ func (m *scannerMetricsUI) View() string {
397397
writtenRows++
398398
}
399399
_ = addRow
400-
addRowF := func(format string, vals ...interface{}) {
400+
addRowF := func(format string, vals ...any) {
401401
s := fmt.Sprintf(format, vals...)
402402
table.Append([]string{s})
403403
writtenRows++
@@ -442,7 +442,7 @@ func (m *scannerMetricsUI) View() string {
442442
if sc.CurrentCycle > 0 {
443443
addRowF(title("Current cycle:")+" %s; Started: %v", ui(sc.CurrentCycle), console.Colorize("metrics-date", sc.CurrentStarted))
444444
} else {
445-
addRowF(title("Current cycle:") + " (between cycles)")
445+
addRowF("%s", title("Current cycle:")+" (between cycles)")
446446
}
447447
}
448448

cmd/admin-service-restart.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (m *serviceRestartUI) View() string {
173173

174174
func initServiceRestartUI(rowCount int, currentCh chan serviceRestartMessage) *serviceRestartUI {
175175
var printColors []*color.Color
176-
for i := 0; i < rowCount; i++ {
176+
for range rowCount {
177177
printColors = append(printColors, getPrintCol(colGreen))
178178
}
179179

0 commit comments

Comments
 (0)