Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Go Features and Case Studies

Go Features and Case Studies

Ian Lewis

April 21, 2015
Tweet

More Decks by Ian Lewis

Other Decks in Technology

Transcript

  1. Image © Renée French. Licensed under CC BY 3.0. Go(lang)

    • Developed at Google • Created to address problems: ◦ Speed of Software Development ◦ Cumbersome Type Systems ◦ Multiple Cores/Concurrency
  2. Image © Renée French. Licensed under CC BY 3.0. Features

    • Compiles to static binary native code • Garbage collector • Strongly typed (types inferred) • Goroutines • Channels • Structs/Interfaces
  3. Image © Renée French. Licensed under CC BY 3.0. Static

    Binary • All Code Needed is Bundled • Avoids Problems with Linking at Runtime • Allows for *very* simple deployment
  4. Image © Renée French. Licensed under CC BY 3.0. Garbage

    Collection • Mark and Sweep in 1.1 • Concurrent Mark and Sweep • Hybrid Mark and Sweep/Concurrent in 1.4 • Concurrent Garbage Collector in 1.5
  5. Image © Renée French. Licensed under CC BY 3.0. Type

    Inference int hoge = 123; // NO!! int fuga = MyFunc(); hoge := 123; // GOOD!! fuga := MyFunc();
  6. Image © Renée French. Licensed under CC BY 3.0. Goroutines

    • Concurrent Function • Light Weight Process • Runs on Multiple Cores • Easy to Write
  7. Image © Renée French. Licensed under CC BY 3.0. Goroutines

    func MyFunc() { resp, err := http.Get("http://google.com/") } go MyFunc() // Concurrent!!!
  8. Image © Renée French. Licensed under CC BY 3.0. Goroutines

    func main() { go MyFunc() // NONO!! // Program will exit to early }
  9. Image © Renée French. Licensed under CC BY 3.0. Channels

    • Like a Queue • Used to Communicate Between Goroutines • Allows for Blocking Operations
  10. Image © Renée French. Licensed under CC BY 3.0. Channels

    func MyFunc(done chan int) { resp, err := http.Get("http://google.com/") done <- 1 }
  11. Image © Renée French. Licensed under CC BY 3.0. Channels

    func main() { done := make(chan int) go MyFunc(done) <-done // GOOD!!! }
  12. Image © Renée French. Licensed under CC BY 3.0. Interfaces

    type Writer interface { Write(p []byte) (n int, err error) }
  13. Image © Renée French. Licensed under CC BY 3.0. Interfaces

    type MyWriter struct {} func (w MyWriter) Write(p []byte) (n int, e error) { ... }
  14. Image © Renée French. Licensed under CC BY 3.0. Vitess

    • Used at Youtube • Sharding MySQL Servers • Serving all YouTube DB traffic since 2011 • http://vitess.io/
  15. Image © Renée French. Licensed under CC BY 3.0. Docker

    • Container Engine • Includes HTTP API Server • Provides Image Packaging Format
  16. Image © Renée French. Licensed under CC BY 3.0. etcd

    • Distributed Key-Value Store • Used for Storing Cluster State/Config • Implements RAFT Protocol
  17. Image © Renée French. Licensed under CC BY 3.0. rocket

    • Container Runner • Supports Docker Containers • Supports Pods
  18. Image © Renée French. Licensed under CC BY 3.0. Kubernetes

    • Container Cluster Manager • Manages a Distributed Cluster • Supports Pods • Provides HTTP API
  19. Image © Renée French. Licensed under CC BY 3.0. GoCon

    2015 Summer • Biggest Go Event in Japan!! • 2015/06/20 (Sat) • Registration starts 2015/05/01
  20. Thank You! QCon Tokyo 2015 Ian Lewis Developer Advocate Google

    Cloud Platform google.com/+IanLewis-hoge @IanMLewis