Go

brew install go --cross-compile-common
eddie cianci
@defeated
Litmus Team Talks
November 19th, 2013
What is Go?
-
language built by Google
-
Ken Thompson
- one of the original UNIX developers
- Rob Pike
- one of the original UTF-8 authors
-
ironically hard to google
- aka "golang"
-
released 1.0 on March 28th, 2012
- current version 1.1.2 on August 13th, 2013
What is Go really?
-
statically-typed, cross-platform, compiled language
- like C without the bullshit
- feels like a scripting language but w/ type safety
-
interesting concurrency model
- goroutines
- channels
- deferred functions
- Not quite OO or FP
- no class inheritance, but can mixing interfaces
- first-class functions
Who uses it?
-
Google
- powers dl.google.com service
- Bitly
-
Heroku
- more and more ops tooling
- Packer (http://packer.io)
- Docker (http://docker.io)
Show me some code!
first.go
package main
import "fmt"
func main() {
fmt.Println("Hi, Litmus!")
} compile & run
go run first.gogo build./first
output
Hi, Litmus!
Show me some code!
demo/libgreeter/libgreeter.go
package libgreeterfunc Greet() string {return message()}func message() string {// var msg string// msg = "Greetings!"msg := "Greetings"return msg}
Show me some code!
demo/greeter-bin.go
package mainimport ("fmt""libgreeter")func main() {fmt.Println(libgreeter.Greet())}
Show me some code!
Testing is baked in
demo/libgreeter/libgreeter_test.go
package libgreeterimport "testing"func TestMessage(t *testing.T) {expected := "Greetings"actual := Greet()if actual != expected {t.Errorf("Expected %v, got %v", expected, actual)}}
Show me some code!
Testing is baked in
run tests ...
cd demo/libgreeter/ go test
run tests ...
cd demo/libgreeter/go test
results ...
PASS
ok _/demo/libgreeter 0.022s Show me some code!
dat concurrency
LIVE CODING!
Resources
In no particular order...
golang
By eddie cianci
golang
- 1,058