Nov 2009 12

The following code compiles without warnings.

package main

import fmto "fmt"
import "os"

func main() {
if (true) {
os.Exit(1);
}
fmto.Printf("hello, world\n");
}

Of course the 8g compiler is still in experimental stage(a non-Beta Google product!) and they’ve made that clear on their documentation. Still, having my first looks at this exciting new language.

Added: the issue has been reported and acknowledged.

Nov 2009 12

ScienceBlogs.com published an opinion on Google’s new Go Language, written by a Googler.

Interesting read, though I feel that if you’re posting an opinion to a Science blog, under the programming section, your examples should compile.


func Factorial(x int) int {
if x == 0 {
return 1;
} else {
return x * Factorial(x - 1);
}
}

test.go:18: function ends without a return statement

It’s not exactly his mistake, the compiler should detect returns that’ll happen on both clauses of an if, or in unconditional if(I know, unconditional if’s don’t make sense, but the compiler should know about it) clauses such as if(true) { return; } . One thing is for sure though: he never ran that code before posting.

The issue with unconditional returns has been reported and is being worked on.