Thursday, November 12, 2009

There we Go.

Last week I visited Google for the first time. I even passed by Rob Pikes office...

Today I'm using the language he and his team just created. Lots of inspirations from C, python, limbo and friends, and I actually had fun playing around with it.

1 package main
2
3 import "fmt"
4
5 func PrintAll(x interface{}) {
6 var str string;
7 switch value := x.(type) {
8 case bool:
9 if value {
10 str = "True"
11 } else {
12 str = "False"
13 }
14 case string:
15 str = value
16 default:
17 return
18 }
19 fmt.Printf(str + "\n")
20 }
21
22
23 func main() {
24 PrintAll("Hello world");
25 PrintAll(true);
26 PrintAll(false);
27 }

Now look at that :-) Hello World, here we Go.
$ 6g test.go && 6l test.6 && ./6.out
Hello world
True
False

PS: "!" replaced with ".", emphasising that I'm talking about "Go" and not the "Go!" language.