Skip to content

Instantly share code, notes, and snippets.

@kenoir
Created October 7, 2012 19:44
Show Gist options
  • Save kenoir/3849352 to your computer and use it in GitHub Desktop.
Save kenoir/3849352 to your computer and use it in GitHub Desktop.
Learning Go
// http://tour.golang.org/#13
package main
import (
"fmt"
"math"
)
var x string
var y, z = "reticulated", "bunghole"
type Prefix []string
func timesByPi(n, m int) (a, b float32) {
a = float32(n) * math.Pi
b = float32(m) * math.Pi
return
}
func (p Prefix) Shift(word string) {
copy(p, p[1:])
p[len(p)-1] = word
}
func main() {
a, b := timesByPi(1, 2)
x = y + z
p := make(Prefix, 2)
p.Shift("Hey")
p.Shift("There")
fmt.Printf("So I put %g in your %g\n", a, b)
fmt.Printf("Yeah and %s\n", x)
fmt.Printf("Lookit: %s\n", p[0])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment