Rob Pike's Go Proverb
Rob Pike在2015年的Gopherfest的演讲,题目是 Go Proverbs. YouTube地址:
Go Proverbs - Rob Pike - Gopherfest - November 18, 2015
他分享了他自己写的几条Go编程的格言,类似 The Zen of Python,但是没那么正式,格言的列表如下,推荐看视频:
- Don’t communicate by sharing memory, share memory by communicating.
- Concurrency is not parallism.
- Channels orchestrate; mutexes serialize.
- The bigger the interface, the weaker the abstraction.
- Make the zero value useful. (e.g.
bytes.Buffer
orsync.Mutex
) interface{}
says nothing.- Gofmt’s style is no one’s favorite, yet gofmt is everyone’s favorite.
- A little copying is better than a little dependency.
- Syscall must always be guarded with build tags.
- Cgo must always be guarded with build tags.
- Cgo is not Go. (他说自己几乎不使用cgo)
- With the
unsafe
package, there are no guarantees. - Clear is better than clever.
- Reflection is never clear.
- Errors are values.
- Don’t just check errors, handle them gracefully.
- Design the architecture, name the components, document the details.
- Documentation is for users.
本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可。