A Quick History

Back in the day

Started in 2009 as an experimental systems programming project by a bunch of Googlers including...

  • Robert Griesemer
    • V8 JavaScript Engine
  • Rob Pike
    • Unix
    • Plan 9
    • Inferno
  • Ken Thompson
    • B
    • Unix
    • Plan 9

Go and Google

  • Go is used by Google
  • Many Go maintainers are employed by Google
  • Go is an open source project with a BSD-style license

Writing Go

Go is Picky

  • If it's worth a warning it's worth an error
    • Unused variables
    • Unused imports
    • Some "style violations"

Idioms in English

  • I'm just pulling your leg.
  • This isn't rocket science.
  • That will cost an arm and a leg!

Idioms in Go

  • Common design patterns that are recognizable to other Go developers.
  • For example:
    • Getters don't need to start with Get
    • Don't insert superfluous semicolons
    • Use a switch statement over a long if-else chain
    • The "comma ok" idiom
  • Idiomatic go code uses common patterns to solve problems

Style in Go

  • There's basically no flexibility.
  • A couple highlights:
    • Tabs not spaces
    • Curly braces open on the same line

Formatting Go

  • Use gofmt to format your code.

Go in the Real World

Why do people like it?

  • Easy to read
  • Easy to write
  • Garbage collected
  • Concurrent programming features

What it's used for

  • General purpose programming
  • Network programming
  • Concurrent programming

Go in CPL

Things to Know

  • We're going to use Go version... 1.9.1
    • 1.6.2 is on the lab machines, but that's "obsolete".
    • Try running code at https://play.golang.org/
  • Your assignment code must be formatted with gofmt
    • Good style is important