当前播放: Practical Go
00:00 / 00:00
标清
  • 标清
1.0x
  • 2.0x
  • 1.5x
  • 1.25x
  • 1.0x
  • 0.5x
网页全屏
全屏
00:00
付费课程,可试看

Practical Go

David Cheney Heptio 资深工程师, 著名Go语言专家

David Cheney,Heptio 资深工程师, 著名 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.

内容大纲

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
展开
¥4.99 购买
开通VIP
2
登录 后留言

精选留言

由作者筛选后的优质留言将会公开显示,欢迎踊跃留言。
收起评论
其他推荐
01:40:05
Apache Kafka,从0.7到1.0:那些年我们踩过的坑
王国璋 Confluent Kafka Streams系统架构师和技术负责人
试看
43:37
工业大数据在智能制造中的应用
孙继珑 积梦智能大数据负责人
试看
46:01
从心开始——谈谈技术管理
唐义哲 英语流利说资深技术经理
试看