Re: [go-nuts] Can't find the syntax error in this "hello-world" snippet. Help.

87 views
Skip to first unread message

Vanja Pejovic

unread,
Aug 15, 2012, 11:31:15 PM8/15/12
to saad...@gmail.com, golan...@googlegroups.com
the " { " must be on the same line as " func main () "

On Wed, Aug 15, 2012 at 11:21 PM, <saad...@gmail.com> wrote:
package main

import "fmt"

func main ()
{
    fmt.Println("Hello, 世界")
}

andrey mirtchovski

unread,
Aug 15, 2012, 11:31:35 PM8/15/12
to saad...@gmail.com, golan...@googlegroups.com

Jesse McNelis

unread,
Aug 16, 2012, 12:14:32 AM8/16/12
to saad...@gmail.com, golan...@googlegroups.com
"prog.go:6: syntax error: unexpected semicolon or newline before {"

It's a pretty clear error message.


--
=====================
http://jessta.id.au

Dave Cheney

unread,
Aug 16, 2012, 2:24:17 AM8/16/12
to saad...@gmail.com, golan...@googlegroups.com
http://golang.org/doc/go_faq.html#semicolons

On Thu, Aug 16, 2012 at 2:18 PM, <saad...@gmail.com> wrote:
> Why should it by in the same line?

Andrew Gerrand

unread,
Aug 16, 2012, 2:33:42 AM8/16/12
to saad...@gmail.com, golan...@googlegroups.com
On 16 August 2012 14:18, <saad...@gmail.com> wrote:
> Why should it by in the same line?

Because that is Go's syntax. It is not the same as C.

Andrew

Jan Mercl

unread,
Aug 16, 2012, 2:55:57 AM8/16/12
to saad...@gmail.com, golan...@googlegroups.com
On Thu, Aug 16, 2012 at 6:18 AM, <saad...@gmail.com> wrote:
Why should it by in the same line?

Because otherwise it's out of the language specification (others already provided the link). So yes, Go is not a (completely) free form[at] language, if someone would ask that. And it's not the only such language, Python being a common example.

-j

Reply all
Reply to author
Forward
0 new messages