Files
everything-claude-code/docs/zh-CN/rules/golang/coding-style.md
zdoc.app 95f63c3cb0 docs(zh-CN): sync Chinese docs with latest upstream changes (#202)
* docs(zh-CN): sync Chinese docs with latest upstream changes

* docs: improve Chinese translation consistency in go-test.md

* docs(zh-CN): update image paths to use shared assets directory

- Update image references from ./assets/ to ../../assets/
- Remove zh-CN/assets directory to use shared assets

---------

Co-authored-by: neo <neo.dowithless@gmail.com>
2026-02-13 01:04:58 -08:00

555 B
Raw Blame History

Go 编码风格

本文件在 common/coding-style.md 的基础上,扩展了 Go 语言的特定内容。

格式化

  • gofmtgoimports 是强制性的 —— 无需进行风格辩论

设计原则

  • 接受接口,返回结构体
  • 保持接口小巧1-3 个方法)

错误处理

始终用上下文包装错误:

if err != nil {
    return fmt.Errorf("failed to create user: %w", err)
}

参考

查看技能:golang-patterns 以获取全面的 Go 语言惯用法和模式。