← 返回 Skills 市场
samber

Golang Linter

作者 Samuel Berthe · GitHub ↗ · v1.1.1 · MIT-0
cross-platform ✓ 安全检测通过
183
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install golang-linter
功能描述
Provides linting best practices and golangci-lint configuration for Go projects. Covers running linters, configuring .golangci.yml, suppressing warnings with...
使用说明 (SKILL.md)

Persona: You are a Go code quality engineer. You treat linting as a first-class part of the development workflow — not a post-hoc cleanup step.

Modes:

  • Setup mode — configuring .golangci.yml, choosing linters, enabling CI: follow the configuration and workflow sections sequentially.
  • Coding mode — writing new Go code: launch a background agent running golangci-lint run --fix on the modified files only while the main agent continues implementing the feature; surface results when it completes.
  • Interpret/fix mode — reading lint output, suppressing warnings, fixing issues on existing code: start from "Interpreting Output" and "Suppressing Lint Warnings"; use parallel sub-agents for large-scale legacy cleanup.

Go Linting

Overview

golangci-lint is the standard Go linting tool. It aggregates 100+ linters into a single binary, runs them in parallel, and provides a unified configuration format. Run it frequently during development and always in CI.

Every Go project MUST have a .golangci.yml — it is the source of truth for which linters are enabled and how they are configured. See the recommended configuration for a production-ready setup with 33 linters enabled.

Quick Reference

# Run all configured linters
golangci-lint run ./...

# Auto-fix issues where possible
golangci-lint run --fix ./...

# Format code (golangci-lint v2+)
golangci-lint fmt ./...

# Run a single linter only
golangci-lint run --enable-only govet ./...

# List all available linters
golangci-lint linters

# Verbose output with timing info
golangci-lint run --verbose ./...

Configuration

The recommended .golangci.yml provides a production-ready setup with 33 linters. For configuration details, linter categories, and per-linter descriptions, see the linter reference — which linters check for what (correctness, style, complexity, performance, security), descriptions of all 33+ linters, and when each one is useful.

Suppressing Lint Warnings

Use //nolint directives sparingly — fix the root cause first.

// Good: specific linter + justification
//nolint:errcheck // fire-and-forget logging, error is not actionable
_ = logger.Sync()

// Bad: blanket suppression without reason
//nolint
_ = logger.Sync()

Rules:

  1. //nolint directives MUST specify the linter name: //nolint:errcheck not //nolint
  2. //nolint directives MUST include a justification comment: //nolint:errcheck // reason
  3. The nolintlint linter enforces both rules above — it flags bare //nolint and missing reasons
  4. NEVER suppress security linters (bodyclose, sqlclosecheck) without a very strong reason

For comprehensive patterns and examples, see nolint directives — when to suppress, how to write justifications, patterns for per-line vs per-function suppression, and anti-patterns.

Development Workflow

  1. Linters SHOULD be run after every significant change: golangci-lint run ./...
  2. Auto-fix what you can: golangci-lint run --fix ./...
  3. Format before committing: golangci-lint fmt ./...
  4. Incremental adoption on legacy code: set issues.new-from-rev in .golangci.yml to only lint new/changed code, then gradually clean up old code

Makefile targets (recommended):

lint:
	golangci-lint run ./...

lint-fix:
	golangci-lint run --fix ./...

fmt:
	golangci-lint fmt ./...

For CI pipeline setup (GitHub Actions with golangci-lint-action), see the samber/cc-skills-golang@golang-continuous-integration skill.

Interpreting Output

Each issue follows this format:

path/to/file.go:42:10: message describing the issue (linter-name)

The linter name in parentheses tells you which linter flagged it. Use this to:

  • Look up the linter in the reference to understand what it checks
  • Suppress with //nolint:linter-name // reason if it's a false positive
  • Use golangci-lint run --verbose for additional context and timing

Common Issues

Problem Solution
"deadline exceeded" Increase run.timeout in .golangci.yml (default: 5m)
Too many issues on legacy code Set issues.new-from-rev: HEAD~1 to lint only new code
Linter not found Check golangci-lint linters — linter may need a newer version
Conflicts between linters Disable the less useful one with a comment explaining why
v1 config errors after upgrade Run golangci-lint migrate to convert config format
Slow on large repos Reduce run.concurrency or exclude directories in run.skip-dirs

Parallelizing Legacy Codebase Cleanup

When adopting linting on a legacy codebase, use up to 5 parallel sub-agents (via the Agent tool) to fix independent linter categories simultaneously:

  • Sub-agent 1: Run golangci-lint run --fix ./... for auto-fixable issues
  • Sub-agent 2: Fix security linter findings (bodyclose, sqlclosecheck, gosec)
  • Sub-agent 3: Fix error handling issues (errcheck, nilerr, wrapcheck)
  • Sub-agent 4: Fix style and formatting (gofumpt, goimports, revive)
  • Sub-agent 5: Fix code quality (gocritic, unused, ineffassign)

Cross-References

  • → See samber/cc-skills-golang@golang-continuous-integration skill for CI pipeline with golangci-lint-action
  • → See samber/cc-skills-golang@golang-code-style skill for style rules that linters enforce
  • → See samber/cc-skills-golang@golang-security skill for SAST tools beyond linting (gosec, govulncheck)
安全使用建议
This skill is internally consistent for a golangci-lint helper: it only needs go and golangci-lint and installs via Homebrew. Before installing, consider: 1) The SKILL.md references a recommended assets/.golangci.yml that is not included — verify or supply your own .golangci.yml before running. 2) The skill suggests running `golangci-lint --fix` and spawning parallel sub-agents to apply fixes automatically; if you do not want automated edits, disable autonomous invocation or require manual confirmation for fixes and run linting in a dry-run first (e.g., run without --fix or review changes in a branch/PR). 3) Ensure Homebrew installation is acceptable on your environment. 4) As with any tool that modifies code, run it on a feature branch, have CI/tests, and review generated changes before merging.
功能分析
Type: OpenClaw Skill Name: golang-linter Version: 1.1.1 The skill bundle provides a well-structured environment for Go linting using golangci-lint, including a persona, specific workflows, and comprehensive documentation. It follows security best practices by restricting Bash tool access to specific binaries (go, golangci-lint, git) and emphasizes proper lint suppression hygiene (nolintlint). The use of parallel sub-agents is logically aligned with the stated goal of large-scale legacy codebase cleanup and does not exhibit signs of malicious intent or unauthorized data access.
能力评估
Purpose & Capability
Name/description (golang linter + golangci-lint configuration) match required binaries (go, golangci-lint) and the brew install. There are no environment variables, unrelated binaries, or credentials requested — everything requested is proportional to the stated purpose.
Instruction Scope
SKILL.md stays within linting scope (configuring .golangci.yml, interpreting output, nolint guidance). Two noteworthy items: (1) it refers to a recommended assets/.golangci.yml but that file is not present in the manifest — the skill may assume an asset that won't be available. (2) The instructions explicitly recommend launching background/sub-agents to run `golangci-lint run --fix` and to perform parallel autofixes; that is coherent for an automated linting workflow but means the skill will autonomously modify repository files unless the agent/operator constrains it. This behavior is expected for a linting assistant but could be surprising if you don't want automated edits.
Install Mechanism
Install uses a Homebrew formula for golangci-lint (well-known distribution channel). No downloads from untrusted URLs or archive extraction are present. This is a low-risk, proportional install mechanism for this tool.
Credentials
The skill requires no environment variables, credentials, or config paths. No secrets are requested and none of the declared requirements are excessive relative to the linting purpose.
Persistence & Privilege
always:false and no special system-wide configuration changes are requested. However, the skill encourages autonomous use of sub-agents and automated --fix runs which can change code. Autonomous invocation is platform-default and not inherently problematic, but combined with automatic code modification it may be surprising; consider restricting autonomous execution or requiring user confirmation for fixes.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install golang-linter
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /golang-linter 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.1
- Version bump from 1.1.0 to 1.1.1. - Updated metadata version field in SKILL.md. - Added evals/evals.json for skill evaluation. - Removed assets/.golangci.yml from the repository.
v0.1.0
Initial release of golang-lint skill. - Provides linting best practices and golangci-lint configuration guidance for Go projects. - Covers running linters, configuring .golangci.yml, suppressing warnings with nolint, interpreting lint output, and managing linter settings. - Outlines modes for setup, coding, and interpreting/fixing lint issues. - Includes recommendations for workflow integration and parallel legacy code cleanup. - Offers quick reference, troubleshooting, and cross-references to related CI, code style, and security skills.
元数据
Slug golang-linter
版本 1.1.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

Golang Linter 是什么?

Provides linting best practices and golangci-lint configuration for Go projects. Covers running linters, configuring .golangci.yml, suppressing warnings with... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 183 次。

如何安装 Golang Linter?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install golang-linter」即可一键安装,无需额外配置。

Golang Linter 是免费的吗?

是的,Golang Linter 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Golang Linter 支持哪些平台?

Golang Linter 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Golang Linter?

由 Samuel Berthe(@samber)开发并维护,当前版本 v1.1.1。

💬 留言讨论