跳转至

Go 编码风格

此文件使用 Go 特定内容扩展 common/coding-style.md。

格式

  • gofmt 和 goimports 是必需的 — 无需讨论风格

设计原则

  • 接收接口,返回结构体
  • 保持接口小巧(1 到 3 个方法)

错误处理

始终使用上下文包装错误:

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

参考

技能:golang-patterns 中可参考全面的 Go 惯用法和模式。

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 ev/ECC