Hello World

4 views
Skip to first unread message

ICeDX

unread,
Jul 9, 2010, 9:00:17 PM7/9/10
to golang-nuts
package main

import "fmt"

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




-=-=-=-
The above code does not actually compile. From the golang.org main
page. Perhaps it should be updated? I think there is a semi colon
right after "fmt"

bflm

unread,
Jul 9, 2010, 9:07:02 PM7/9/10
to golang-nuts
The above code does actually compile (6g/5924e1889138 tip) and the
semicolon after "fmt" is not required.

$ cat tmp.go && make clean tmp && ./tmp
package main

import "fmt";

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

rm -rf *.o *.a *.[568vq] [568vq].out tmp
/home/myname/bin/6g -o _go_.6 tmp.go
/home/myname/bin/6l -o tmp _go_.6
Hello, 世界
$

Steven

unread,
Jul 9, 2010, 9:07:42 PM7/9/10
to ICeDX, golang-nuts
The code compiles fine with a recent version of Go. The need for a semicolon was done away with months ago.

bflm

unread,
Jul 9, 2010, 9:11:22 PM7/9/10
to golang-nuts
On Jul 10, 3:07 am, bflm <befelemepesev...@gmail.com> wrote:
> import "fmt";

Note: I've tested both versions but then wrongly posted that with the
semicolon.

jimmy frasche

unread,
Jul 9, 2010, 9:16:39 PM7/9/10
to ICeDX, golang-nuts
On Fri, Jul 9, 2010 at 6:00 PM, ICeDX <blo...@gmail.com> wrote:
> The above code does not actually compile. From the golang.org main
> page.

Did you save the file so that it was UTF-8 encoded?

Andrew Gerrand

unread,
Jul 10, 2010, 4:41:23 AM7/10/10
to ICeDX, golang-nuts
On 10 July 2010 11:00, ICeDX <blo...@gmail.com> wrote:
> The above code does not actually compile. From the golang.org main
> page. Perhaps it should be updated? I think there is a semi colon
> right after "fmt"

It works fine on my machine, using the latest release compiler:

--

amchitka:~ nf$ cat > hello.go
package main

import "fmt"

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

amchitka:~ nf$ 6g hello.go && 6l hello.6
amchitka:~ nf$ ./6.out
Hello, 世界

--

How did you create the source file? What is the error you receive?

Andrew

Reply all
Reply to author
Forward
0 new messages