Created
October 7, 2012 19:44
-
-
Save kenoir/3849352 to your computer and use it in GitHub Desktop.
Learning Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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