AgentSkillsCN

go-style-review

基于 Google Go 风格指南、《Effective Go》以及代码评审意见,提供 Go 代码风格评审指南。当您需要:(1) 审核 Go 代码的风格合规性,(2) 编写新的 Go 代码,(3) 重构现有 Go 代码,(4) 进行代码评审时,此指南将为您提供全面而实用的指导。内容涵盖命名规范、错误处理、并发编程、测试策略、数据类型、函数设计、接口设计,以及代码组织方式。

SKILL.md
--- frontmatter
name: go-style-review
description: "Go code style review guide based on Google Go Style Guide, Effective Go, and Code Review Comments. Use when: (1) reviewing Go code for style compliance, (2) writing new Go code, (3) refactoring existing Go code, (4) conducting code reviews. Covers naming, error handling, concurrency, testing, data types, functions, interfaces, and code organization."

Go Style Review

Core Principles

  1. Clarity over cleverness - Code should be obvious to readers
  2. Simplicity - Accomplish goals in the most straightforward way
  3. Consistency - Match surrounding code and project conventions
  4. Minimal indentation - Handle errors early, keep happy path unindented

Workflow

  1. Run automated checks (make lint, make fmt or gofmt, goimports)
  2. Review against essential checklist: references/essential/checklist.md
  3. For specific questions, consult: references/comprehensive/{topic}.md

Reference Navigation

Quick reviews (default):

  • references/essential/checklist.md - Condensed, actionable rules

Deep dives by topic:

  • references/comprehensive/naming.md - Package names, identifiers, receivers
  • references/comprehensive/errors.md - Error handling, panic/recover
  • references/comprehensive/concurrency.md - Goroutines, channels, context
  • references/comprehensive/testing.md - Test quality and patterns
  • references/comprehensive/code-organization.md - Imports, packages, structure
  • references/comprehensive/data-types.md - new vs make, slices, maps
  • references/comprehensive/functions.md - Multiple returns, defer
  • references/comprehensive/interfaces.md - Embedding, type assertions

Sources