Skip to content

refactor(server): 代码质量改进和 Go 1.21+ 现代化#18

Merged
wutongci merged 1 commit into
astercloud:mainfrom
lwmacct:tmp/251214-0053
Dec 13, 2025
Merged

refactor(server): 代码质量改进和 Go 1.21+ 现代化#18
wutongci merged 1 commit into
astercloud:mainfrom
lwmacct:tmp/251214-0053

Conversation

@lwmacct

@lwmacct lwmacct commented Dec 13, 2025

Copy link
Copy Markdown
Contributor

Summary

  • 使用 slices.Contains 替换手写循环查找逻辑(middleware, dashboard_events)
  • 使用 maps.Copy 替换手写 map 复制循环(health.go)
  • 修复 errcheck 警告:显式忽略 fmt.Sscanfconn.Close 返回值
  • 为预留的 registerDashboardRoutes 函数添加 //nolint:unused 指令
  • 修复测试文件中的 errcheck 警告(loader_test.go, executor_test.go)

Changes

文件 修改
cmd/aster-server/main.go 显式忽略 fmt.Sscanf 错误
server/handlers/remote_agent.go 显式忽略 conn.Close() 错误
server/middleware.go slices.Contains 替换循环
server/handlers/dashboard_events.go slices.Contains 替换 2 处循环
server/observability/health.go maps.Copy 替换循环
server/routes.go 保留预留函数,添加 //nolint:unused
pkg/config/loader_test.go 修复 os.Setenv/Unsetenv errcheck
pkg/executionplan/executor_test.go 修复 Execute errcheck

Test plan

  • golangci-lint run --new 通过(0 issues)
  • go build ./cmd/aster ./cmd/aster-server 通过
  • pre-commit hooks 全部通过

- 使用 slices.Contains 替换手写循环查找逻辑
- 使用 maps.Copy 替换手写 map 复制循环
- 修复 errcheck 警告: 显式忽略 fmt.Sscanf 和 conn.Close 返回值
- 为预留的 registerDashboardRoutes 函数添加 nolint:unused 指令
- 修复测试文件中的 errcheck 警告
- 修复 sandbox 使用 bash 代替 sh 以支持 ulimit -u
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/sandbox/local.go 66.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@wutongci
wutongci merged commit 7b599fd into astercloud:main Dec 13, 2025
3 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.

3 participants