Skip to content

fix modernize fmt flag - #135

Merged
AlexStocks merged 3 commits into
apache:masterfrom
222twotwotwo:fix-GitHub-Actions-CI-failed-in-the-`Check-Code-Format`-step
Jul 17, 2026
Merged

fix modernize fmt flag#135
AlexStocks merged 3 commits into
apache:masterfrom
222twotwotwo:fix-GitHub-Actions-CI-failed-in-the-`Check-Code-Format`-step

Conversation

@222twotwotwo

@222twotwotwo 222twotwotwo commented Jul 16, 2026

Copy link
Copy Markdown

What this PR does:

Updates the fmt target in Makefile to use the current modernize CLI flag -any instead of the removed -category=efaceany flag.

This fixes the GitHub Actions Check Code Format step failure caused by modernize@latest no longer supporting -category.

Which issue(s) this PR fixes:

Fixes #134

Special notes for your reviewer:

Local validation:

go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -any -fix -test ./...
go fmt ./...
imports-formatter
go test ./... -coverprofile=coverage.txt -covermode=atomic
go vet ./...
golangci-lint run ./... --timeout=10m

Does this PR introduce a user-facing change?:

NONE

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the repository’s formatting workflow to align with the current modernize CLI, fixing CI failures in the “Check Code Format” step (Issue #134).

Changes:

  • Replace the removed modernize flag -category=efaceany with the current -any flag in the fmt Makefile target.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile Outdated
fmt: install-imports-formatter
# replace interface{} with any
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -category=efaceany -fix -test ./...
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -any -fix -test ./...

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 补充当前可复现证据:本次 CI 实际解析到 gopls v0.23.0,它要求 Go 1.26,因此虽然 workflow 声明 Go 1.23,格式步骤仍自动下载并切换到了 Go 1.26.5;在 GOTOOLCHAIN=go1.23.12 下该命令会直接失败。另外,gopls v0.21.0+ 已把这个 gopls/internal/.../cmd/modernize 入口标记为 deprecated,要求迁移到公开的 golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize。因此只替换 flag 仍保留了同一类上游漂移风险。建议改用公开入口、固定工具版本,并让该版本的最低 Go 要求与 CI 明确对齐。

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Comment thread .github/workflows/github-actions.yml Outdated
matrix:
go_version:
- '1.23'
- '1.24'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] 保留 Go 1.23 兼容性测试,不要用工具要求替换代码测试矩阵

go.mod 仍声明 go 1.23,而这里是唯一的单测/Lint 矩阵。直接改成 1.24 后,后续代码即使引用 Go 1.24 新增的标准库 API 也会在 CI 通过,但 Go 1.23 用户会编译失败。x/tools v0.38.0 的 Go 1.24 要求只属于格式工具:请保留 Go 1.23 的代码测试任务,并把 format 拆到单独的 Go 1.24 job/step,或仅为该命令显式选择 1.24 工具链;如果项目确实要把最低版本提升到 1.24,则应同时更新 go.mod 和升级说明。

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK,done.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

明确一下,正确的最小改法就是当前 Head c50b47ea

  • .github/workflows/github-actions.yml 继续使用 Go 1.23,不提升唯一的代码测试矩阵;
  • Makefile 中的 modernize 使用公开入口并固定 v0.38.0,只在该命令前设置 GOTOOLCHAIN=go1.24.0

我已在 WSL 验证 GOTOOLCHAIN=go1.23.12 go vet ./...,以及 GOTOOLCHAIN=go1.24.0 go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@v0.38.0 -any -diff -test ./...,两条命令均通过,工作区没有产生改动。这个 P1 在代码层面已经修复,不需要再调整实现;当前新 Head 尚无 checks,接下来只需批准或触发 Actions,并确认检查通过。

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已按照建议做出修改

@AlexStocks
AlexStocks merged commit b6f26d2 into apache:master Jul 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] make fmt fails because modernize@latest no longer supports -category

3 participants