来QCon,和Dave Cheney学习Go语言最佳实践

2018 年 10 月 9 日 QCon

在即将于10月18~20日举行的QCon上海2018上,我们邀请到了知名的Go语言专家Dave Cheney。相信很多有意学习Go语言的朋友都看过他的博客:https://dave.cheney.net/about


Dave Cheney 


Dave是Heptio的资深工程师。Heptio位于西雅图,致力于帮助开发者高效使用Kubernetes。


Dave是开源贡献者,Go编程语言项目组成员。他经常在技术社区演讲,分享软件设计、性能和Go语言相关主题。


这次他将带来两个演讲。


一个是《The past, present, and future of Go》:


Go was introduced as a new open source language on November 10th, 2009. Go is a language for engineering teams who seek to build fast, scalable, and most importantly maintainable, software. This talk will reflect on the success Go has enjoyed over the past nine years, and give the audience an overview of the four new additions coming to Go 2.0; dependency management, error handling, error values, and generics.


另一个是《Practical Go》:


Go is a language designed for engineering teams. It's central themes are simplicity, readability, and maintainability. This talk will provide best practice real world advice for teams building projects in Go covering five areas; idiomatic code, package and api design, error handling, concurrency, and testing. 


因为细节比较多,第2个演讲他将用90分钟时间分享Go最佳实践。具体大纲如下。


Identifiers


  1. Choose identifiers for clarity, not brevity

  2. Use a consistent declaraton style


Package Design


  1. A good package starts with its name An identifier’s name includes its package name Prefer lower case package names and import paths

  2. Rather than nesting deeply, return early

  3. Make the zero value useful

  4. Eschew package level state. No package level variables. Avoid global side effects.


Project Structure


  1. Consider fewer, larger packages Arrange code into files by import statements. Prefer nouns for file names. Eschew elaborate package hierarchies, resist the desire to apply taxonomy

  2. Keep package main small as small as possible


API Design


  1. Design APIs that are hard to misuse. Design APIs for their default use case.

  2. Prefer var args to []T parameters

  3. Let callers define the interface they require

  4. Prefer streaming interfaces

  5. Use type assertions for optional behaviour


Error handling


  1. Elminate handling by eliminating errors

  2. Only handle an error once


Concurrency


  1. Never start a goroutine without when it will stop. When sending or receiving on a channel, consider what happens if the other party never receives the message

  2. Keep yourself busy while waiting for a goroutine. or, do the work yourself.

  3. Leave concurrency to the caller


感兴趣的朋友可以点击阅读原文,了解更多演讲信息。



登录查看更多
0

相关内容

《工程》是中国工程院(CAE)于2015年推出的国际开放存取期刊。其目的是提供一个高水平的平台,传播和分享工程研发的前沿进展、当前主要研究成果和关键成果;报告工程科学的进展,讨论工程发展的热点、兴趣领域、挑战和前景,在工程中考虑人与环境的福祉和伦理道德,鼓励具有深远经济和社会意义的工程突破和创新,使之达到国际先进水平,成为新的生产力,从而改变世界,造福人类,创造新的未来。 期刊链接:https://www.sciencedirect.com/journal/engineering
知识图谱推理,50页ppt,Salesforce首席科学家Richard Socher
专知会员服务
105+阅读 · 2020年6月10日
深度强化学习策略梯度教程,53页ppt
专知会员服务
176+阅读 · 2020年2月1日
强化学习最新教程,17页pdf
专知会员服务
168+阅读 · 2019年10月11日
机器学习入门的经验与建议
专知会员服务
90+阅读 · 2019年10月10日
计算机视觉最佳实践、代码示例和相关文档
专知会员服务
17+阅读 · 2019年10月9日
机器学习相关资源(框架、库、软件)大列表
专知会员服务
38+阅读 · 2019年10月9日
最佳实践:阿里巴巴数据中台
AliData
26+阅读 · 2019年7月26日
网易游戏海外AWS实践分享
高效开发运维
3+阅读 · 2019年5月21日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
16+阅读 · 2018年12月24日
五个精彩实用的自然语言处理资源
机器学习研究会
6+阅读 · 2018年2月23日
【推荐】自然语言处理(NLP)指南
机器学习研究会
35+阅读 · 2017年11月17日
机器学习实践指南
Linux中国
8+阅读 · 2017年9月28日
【推荐】决策树/随机森林深入解析
机器学习研究会
5+阅读 · 2017年9月21日
解密谷歌机器学习工程最佳实践——机器学习43条军规
人工智能头条
3+阅读 · 2017年9月19日
最佳实践:深度学习用于自然语言处理(三)
待字闺中
3+阅读 · 2017年8月20日
Heterogeneous Graph Transformer
Arxiv
27+阅读 · 2020年3月3日
Question Generation by Transformers
Arxiv
5+阅读 · 2019年9月14日
Star-Transformer
Arxiv
5+阅读 · 2019年2月28日
Semantics of Data Mining Services in Cloud Computing
Arxiv
4+阅读 · 2018年10月5日
Knowledge Based Machine Reading Comprehension
Arxiv
4+阅读 · 2018年9月12日
Arxiv
7+阅读 · 2018年6月1日
Arxiv
3+阅读 · 2018年3月28日
VIP会员
相关VIP内容
知识图谱推理,50页ppt,Salesforce首席科学家Richard Socher
专知会员服务
105+阅读 · 2020年6月10日
深度强化学习策略梯度教程,53页ppt
专知会员服务
176+阅读 · 2020年2月1日
强化学习最新教程,17页pdf
专知会员服务
168+阅读 · 2019年10月11日
机器学习入门的经验与建议
专知会员服务
90+阅读 · 2019年10月10日
计算机视觉最佳实践、代码示例和相关文档
专知会员服务
17+阅读 · 2019年10月9日
机器学习相关资源(框架、库、软件)大列表
专知会员服务
38+阅读 · 2019年10月9日
相关资讯
最佳实践:阿里巴巴数据中台
AliData
26+阅读 · 2019年7月26日
网易游戏海外AWS实践分享
高效开发运维
3+阅读 · 2019年5月21日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
16+阅读 · 2018年12月24日
五个精彩实用的自然语言处理资源
机器学习研究会
6+阅读 · 2018年2月23日
【推荐】自然语言处理(NLP)指南
机器学习研究会
35+阅读 · 2017年11月17日
机器学习实践指南
Linux中国
8+阅读 · 2017年9月28日
【推荐】决策树/随机森林深入解析
机器学习研究会
5+阅读 · 2017年9月21日
解密谷歌机器学习工程最佳实践——机器学习43条军规
人工智能头条
3+阅读 · 2017年9月19日
最佳实践:深度学习用于自然语言处理(三)
待字闺中
3+阅读 · 2017年8月20日
相关论文
Heterogeneous Graph Transformer
Arxiv
27+阅读 · 2020年3月3日
Question Generation by Transformers
Arxiv
5+阅读 · 2019年9月14日
Star-Transformer
Arxiv
5+阅读 · 2019年2月28日
Semantics of Data Mining Services in Cloud Computing
Arxiv
4+阅读 · 2018年10月5日
Knowledge Based Machine Reading Comprehension
Arxiv
4+阅读 · 2018年9月12日
Arxiv
7+阅读 · 2018年6月1日
Arxiv
3+阅读 · 2018年3月28日
Top
微信扫码咨询专知VIP会员