hello world syntax error.

17 views
Skip to first unread message

Chris Bruner

unread,
Dec 4, 2010, 5:21:53 AM12/4/10
to golan...@googlegroups.com
Running under windows, and I'm getting a syntax error. Under the
golang.org paste it works.

package main

import fmt "fmt"


func main() { /// line 6
fmt.Printf("hello, word \n")
}


$ 8g hello.go
hello.go:6: syntax error near "<string>"

Also in the getting started hello world, it had
import "fmt"
but in the examples it has
import "fmt"

(Both give the same syntax error).
$GOOS=windows
$GOARCH=386

using binary go from http://code.google.com/p/gomingw/
update 2010-12-02


Andrew Gerrand

unread,
Dec 5, 2010, 1:33:57 AM12/5/10
to Chris Bruner, golan...@googlegroups.com
On 4 December 2010 19:21, Chris Bruner <cbr...@quadro.net> wrote:
> Running under windows, and I'm getting a syntax error. Under the golang.org
> paste it works.
>
> package main
>
> import fmt "fmt"
>
>
> func main() {   /// line 6
>        fmt.Printf("hello, word \n")
> }
>
>
> $ 8g hello.go
> hello.go:6: syntax error near "<string>"
>
> Also in the getting started hello world, it had
> import "fmt"
> but in the examples it has
> import "fmt"

These both look the same to me. Are there any non-ascii characters in
the file? If you copy and paste this code, does it work?

package main
import "fmt"
func main() { fmt.Println("Hi") }

Andrew

Cory Mainwaring

unread,
Dec 5, 2010, 1:12:18 PM12/5/10
to Andrew Gerrand, Chris Bruner, golan...@googlegroups.com
Yes, that would error out. It would error out quite easily. Copy and
paste your code into notepad. You should see a bunch of A's with
accents, because in Windows, that's what they are.

In UTF-8, the same character is whitespace.

Make sure to use a Windows encoding for Go programs compiled on Windows.

Reply all
Reply to author
Forward
0 new messages