npx skills add https://github.com/cxuu/golang-skills --skill go-linting来源 : Uber Go 风格指南
比任何“官方推荐”的检查工具集更重要的是:在整个代码库中保持一致的检查规范。
一致的代码检查有助于发现常见问题,并为代码质量设立高标准,同时避免不必要的硬性规定。
来源 : Uber Go 风格指南
这些检查工具能在保持高质量标准的同时,捕获最常见的问题:
| 检查工具 | 用途 |
|---|---|
| errcheck | 确保错误得到处理 |
| goimports | 格式化代码并管理导入 |
| revive | 常见风格错误(golint 的现代替代品) |
| govet | 分析代码中的常见错误 |
| staticcheck |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 各种静态分析检查 |
注意 :
revive是现已弃用的golint的现代、更快的继任者。
来源 : Uber Go 风格指南
使用 golangci-lint 作为你的检查运行器:
参见 uber-go/guide 仓库中的 示例 .golangci.yml。
在你的项目根目录创建 .golangci.yml 文件:
linters:
enable:
- errcheck
- goimports
- revive
- govet
- staticcheck
linters-settings:
goimports:
local-prefixes: github.com/your-org/your-repo
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: error-return
- name: error-strings
- name: exported
run:
timeout: 5m
# 安装
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# 运行所有检查工具
golangci-lint run
# 在特定路径上运行
golangci-lint run ./pkg/...
| 任务 | 命令/操作 |
|---|---|
| 安装 golangci-lint | go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest |
| 运行检查工具 | golangci-lint run |
| 在路径上运行 | golangci-lint run ./pkg/... |
| 配置文件 | 项目根目录下的 .golangci.yml |
| CI 集成 | 在流水线中运行 golangci-lint run |
| 当你需要... | 使用 |
|---|---|
| 错误处理覆盖率 | errcheck |
| 导入格式化 | goimports |
| 风格一致性 | revive |
| 错误检测 | govet, staticcheck |
| 以上所有 | 使用配置好的 golangci-lint |
go-style-corego-testing每周安装量
161
代码仓库
GitHub 星标数
34
首次出现
2026年1月27日
安全审计
安装于
github-copilot152
gemini-cli151
opencode151
codex150
kimi-cli148
amp147
Source : Uber Go Style Guide
More important than any "blessed" set of linters: lint consistently across a codebase.
Consistent linting helps catch common issues and establishes a high bar for code quality without being unnecessarily prescriptive.
Source : Uber Go Style Guide
These linters catch the most common issues while maintaining a high quality bar:
| Linter | Purpose |
|---|---|
| errcheck | Ensure errors are handled |
| goimports | Format code and manage imports |
| revive | Common style mistakes (modern replacement for golint) |
| govet | Analyze code for common mistakes |
| staticcheck | Various static analysis checks |
Note :
reviveis the modern, faster successor to the now-deprecatedgolint.
Source : Uber Go Style Guide
Use golangci-lint as your lint runner:
See the example .golangci.yml from uber-go/guide.
Create .golangci.yml in your project root:
linters:
enable:
- errcheck
- goimports
- revive
- govet
- staticcheck
linters-settings:
goimports:
local-prefixes: github.com/your-org/your-repo
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: error-return
- name: error-strings
- name: exported
run:
timeout: 5m
# Install
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Run all linters
golangci-lint run
# Run on specific paths
golangci-lint run ./pkg/...
| Task | Command/Action |
|---|---|
| Install golangci-lint | go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest |
| Run linters | golangci-lint run |
| Run on path | golangci-lint run ./pkg/... |
| Config file | .golangci.yml in project root |
| CI integration | Run golangci-lint run in pipeline |
| When you need... | Use |
|---|---|
| Error handling coverage | errcheck |
| Import formatting | goimports |
| Style consistency | revive |
| Bug detection | govet, staticcheck |
| All of the above | golangci-lint with config |
go-style-corego-testingWeekly Installs
161
Repository
GitHub Stars
34
First Seen
Jan 27, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot152
gemini-cli151
opencode151
codex150
kimi-cli148
amp147
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
106,200 周安装