Go in 7 minutes
11 June 2013
Thomas Kappler
www.thomaskappler.net
Thomas Kappler
www.thomaskappler.net

package main
import (
    "fmt"
)
func main() {
    fmt.Println("Hello, λ!")
}Plus some awesomeness!
Lightweight pseudo-threads passing data.
Goroutines & channels.
    "Don't communicate by sharing memory, share memory by communicating."
    ― Rob Pike
  
ch := make(chan int)
go func() {
    for i := 0; i < 10; i++ {
        ch <- i
    }
    close(ch)
}()
for num := range ch {
    fmt.Println(num)
}ch := make(chan int)
go func() {
    for i := 0; i < 10; i++ {
        time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
        ch <- i
    }
    close(ch)
}()
for {
    select {
    case num := <-ch:
        fmt.Println(num)
    case <-time.After(1 * time.Second):
        fmt.Println("Timeout!")
        break
    }
}Make anything typesafe.
type Lang string
type Foo struct { ... }Make anything typesafe.
type Lang string
type Foo struct { ... }Put methods on anything.
func (l Lang) Awesome() bool { return l == "Go" }Make anything typesafe.
type Lang string
type Foo struct { ... }Put methods on anything.
func (l Lang) Awesome() bool { return l == "Go" }Compose without annoying delegates.
type WebTuesdayTalk struct {
    Lang
    presenter string
}Structural typing = "static duck typing".
func (f *File) Read(b []byte) (n int, err...)
implements
type Reader interface {
    Read(p []byte) (n int, err error)
}-> Implement interfaces without creating a dependency.
The Go programming language tour