返回 Skill 列表
extension
分类: 开发与工程无需 API Key

effective-go

应用来自golang.org/doc/effective_go的Go最佳实践、惯用法和约定。在编写、审查或重构Go代码时使用,以确保实现符合惯用法、简洁且高效。

person作者: jakexiaohubgithub

Effective Go

Apply best practices and conventions from the official Effective Go guide to write clean, idiomatic Go code.

When to Apply

Use this skill automatically when:

  • Writing new Go code
  • Reviewing Go code
  • Refactoring existing Go implementations

Core Concepts

| Topic | Description | Reference | |-------|-------------|-----------| | Formatting | Always use gofmt - this is non-negotiable | core-formatting | | Naming | MixedCaps for exported, mixedCaps for unexported | core-naming | | Error Handling | Check errors, return them, don't panic | core-error-handling | | Concurrency | Share memory by communicating (use channels) | core-concurrency | | Interfaces | Keep small (1-3 methods ideal); accept interfaces, return concrete types | core-interfaces | | Documentation | Document all exported symbols | core-documentation |

Key Reminders

Follow the conventions and patterns documented at https://go.dev/doc/effective_go:

  • Formatting: Use gofmt - this is non-negotiable
  • Naming: No underscores, use MixedCaps for exported names
  • Error handling: Always check errors; return them, don't panic
  • Concurrency: Share memory by communicating
  • Interfaces: Keep small and accept interfaces, return structs
  • Documentation: Document all exported symbols

References

  • Official Guide: https://go.dev/doc/effective_go
  • Code Review Comments: https://github.com/golang/go/wiki/CodeReviewComments
  • Standard Library: Use as reference for idiomatic patterns