tags:

views:

667

answers:

2

I got Go to compile:

0 known bugs; 0 unexpected bugs

and typed in the "hello world":

package main

import "fmt"

func main() {
  fmt.Printf("Hello, 世界\n")
}

Then I tried to compile it, but it wouldn't go:

$ 8c gotest2
gotest2:1 not a function
gotest2:1 syntax error, last name: main

This is going on on Ubuntu Linux on Pentium. Go installed and passed its tests. So where did I go wrong? Can someone tell me where to go from here?

I also tried this program:

package main

import fmt "fmt"  // Package implementing formatted I/O.


func main() {
    fmt.Printf("Hello, world; or Καλημέρα κόσμε; or こんにちは 世界\n");
}

But this was also no go (must stop making go puns):

$ 8c gotest3.go
gotest3.go:1 not a function
gotest3.go:1 syntax error, last name: main
A: 

Also you seem to be missing an fmt

import fmt "fmt"

as found in the tutorial in the first answer's link

Ah, I see you have tried that now...

ulkash
Out of curiosity, do both versions of the code compile now?It's interesting that the example on the GoLang.org homepage is slightly different to that in the tutorial.
ulkash
Yes, they both compile.
Kinopiko
+5  A: 

You're using 8c, which is the c compiler. 8g will compile go, and 8l will link.

Scott Wales
8c is the plan-9 c compiler which comes with go, it is seperate from you're systems c compiler
Scott Wales
You are right .
Kinopiko
In regards to the other answers, a semicolon is optional at the end of a block (supposedly for one-liners, although it seems a poor idea to me) and the import fmt "fmt" renames a namespace, so you can use e.g. import goformat "fmt" and then call goformat.Print()
Scott Wales