[译]参考资料: 地道的GO代码

目录 [−]

  1. Accept interfaces, return concrete types
  2. Code Review Comments
  3. Effective Go
  4. Go Patterns
  5. Go Proverbs
  6. Go and the Zen of Python
  7. Go by Example
  8. Idiomatic Doc Comments: Document Your Function, Not Your Function Signature
  9. Idiomatic Go
  10. Idiomatic Go Readability
  11. Idiomatic Go Tests
  12. Idiomatic Go Trickshttps://medium.com/@matryer/idiomatic-go-tricks-62abea5c50fb
  13. Itty Bitty Go Idiom: If Without Else
  14. Things I learned teaching Go
  15. What is idiomatic Go?
  16. When in Go, do as Gophers do
  17. 50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs

原文: Idiomatic Go

什么样的代码才算最地道的Go代码? 这个问题经常被人问起,但是确不太好回答。部分原因在于我们还在摸索之中,抑或Go还是一个年轻的语言。随着语言和社区的逐渐成熟,老司机们才会对地道的Go代码达成共识。

请注意,地道的代码不是限制你的规则,而是代码指导。工作正常的代码比地道的代码更重要。因为所谓的地道,只是大家达成的一种共识,所以"不地道"的的代码不一定代表着错误。

既然没有确定的答案,我在本文中收集了相关的参考资料, 以飨读者。

Accept interfaces, return concrete types

Craig Brookes 2016-11-02

解释什么是地道的代码, 为什么你要遵循它。

Code Review Comments

在Code review的时候一套通用的指导, 简短几句话介绍编写代码的地道的方式。 Go官方出品。

Effective Go

Go开发组提供了编写清晰、地道的Go代码的小窍门。这是Go程序员必读的参考文档, 不止有地道的代码指导,而且还有Go各种特性的背后的考量。

Go Patterns

Tamer Tas

关于Go语言的设计模式和应用程序模式的集合。

Go Proverbs

Rob Pike收集的简单、富有诗意的精辟语录, 解释Go语言深层次的哲学、以更容易理解方式。真正理解并应用它们会让你成为Go大牛。

Go and the Zen of Python

Andrew Gerrand

比较 Python 和 Go 之禅意。

Go by Example

使用带注解的例子教授Go, 会讨论什么样的代码才是地道的代码。

Idiomatic Doc Comments: Document Your Function, Not Your Function Signature

Katrina Owen 2015-10-14

通过示例解释如何为Go函数编写有帮助的注释。

Idiomatic Go

Dmitri Shuralyov

Code Review Comments的补充,通过令人信服理由和参考文献, 列举了地道的Go代码指导。

Idiomatic Go Readability

haya14busa

地道的可读性的Go代码的实践经验和窍门, 包括自动和手动方式。

Idiomatic Go Tests

Craig Brookes

作者通过例子解释地道的Go测试应该怎么做。

Idiomatic Go Trickshttps://medium.com/@matryer/idiomatic-go-tricks-62abea5c50fb

Mat Ryer video slides 2016-08-18

一些技巧和窍门让你像个老司机一样谈论Go。

Itty Bitty Go Idiom: If Without Else

Katrina Owen 2015-10-16

为什么你通常看到的Go代码中if语句没有else分支, 这篇文章解释了这个问题。

Things I learned teaching Go

Francesc Campoy Flores 2014-10-10

It's better because it's what other people in the community expect.

通过教学总结的经验。

What is idiomatic Go?

这是reddit是的一篇讨论,对一个代码库的中的非地道Go代码的抨击。评论显示这些地道代码指导对社区的帮助和伤害。

When in Go, do as Gophers do

Fumitoshi Ukai 2014-11-30

通过Review对Go项目代码的提交学到的一些地道的编写Go代码的方式。作者作为 Go Readability Approver,一年中review大约200左右的 CL, 在本文中总结了他所学到的。

一旦我发现了更多的参考资料,我会更新这篇文章, 所以记得收藏本文。

当然作为译者,我也会补充更多的参考资料,如果你发现了一些关于这方面的参考资料,记得在评论中贴出来哦。

50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs

Kyle Quest

Go的50度灰:Golang新开发者要注意的陷阱和常见错误