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

Introduction to Go

Introduction to Go

A beginner's introduction to go. Presented at DevComo

Avatar for James Carr

James Carr

June 21, 2017

More Decks by James Carr

Other Decks in Technology

Transcript

  1. Why Go? • Single Binary Deploy • Really Good Standard

    Library • Concurrency • Tooling • Very clean syntax
  2. This Talk • Going to aim at getting started •

    Walk through basic syntax, idioms and tooling • Accessible for beginners!
  3. Tooling Built In • `go fmt` - format go code

    • `go test` - runs unit tests • `go get` - builtin for fetching 3rd party libraries / tools • `go install` - compile and install packages and dependencies
  4. Standard Library • Comes with a huge chunk of packages

    for various common tasks • Io • net/http • encoding/json and encoding/xml • testing • etc.
  5. Compiling • Compilation within seconds • No waiting for interpreter

    or JVM to spin up • Target multiple platforms with cross-compilation • Increased efficiency, very quick feedback loop • Easy deployment - no need for virtualenvs, ensuring correct ruby version, heavy JVM, etc • Just compile and deploy a single binary
  6. Concurrency • Goroutines • Very lightweight way to run multiple

    functions concurrently. Can run hundreds of thousands and implementation varies by OS • Channels • Very elegant way to communicate between goroutines
  7. Note About Interfaces • Very different from most languages, very

    implicit • Only defines required methods, implementation does not need to reference the interface name • Really good blog post on Go Interfaces: http:// jordanorelli.com/post/32665860244/how-to-use- interfaces-in-go
  8. Channels Features • Can enforce read-only / write-only usage •

    Buffer to a specific size • Can iterate over new data as it becomes available • Use switch to handle new messages asynchronously.
  9. Some Resources! • Go by example • #go-nuts on free

    node • Go slack group • Devcomo!