main.go:1:1: expected 'package', found 'EOF'

3,656 views
Skip to first unread message

Roelof Wobben

unread,
Jan 23, 2015, 9:04:20 AM1/23/15
to golan...@googlegroups.com
Hello,

I have this piece :

~~~

package main

import "fmt"

func main() {
    var x string = "Hello World"
    fmt.Println(x)
}

~~~

but when I do go run main,go I see this error :  main.go:1:1: expected 'package', found 'EOF'
which surprise me because line 1 starts with a package


Roelof

Nico

unread,
Jan 23, 2015, 9:16:15 AM1/23/15
to golan...@googlegroups.com
Did you save before calling GoRun?

Roelof Wobben

unread,
Jan 23, 2015, 9:36:34 AM1/23/15
to golan...@googlegroups.com
I thought I did but I saved it one more time and now it works.

Thanks, now I can work on the golang book to learn go.

Roelof


Op vrijdag 23 januari 2015 15:16:15 UTC+1 schreef Nico:

rame...@gmail.com

unread,
Apr 19, 2017, 8:45:07 PM4/19/17
to golang-nuts
Thank you, Nico.

Francis

unread,
Nov 16, 2021, 11:40:37 PM11/16/21
to golang-nuts
Thank you all, CRTL + S , was the trick!.. I had a similar problem.

Cengiz Korkmaz

unread,
Feb 10, 2024, 7:51:36 PM2/10/24
to golang-nuts
Thank you, just save it before run. no correct answers anywhere. 

Ardhian Galih

unread,
Aug 5, 2025, 11:38:36 AMAug 5
to golang-nuts
finally after trying many times, its worked
Reply all
Reply to author
Forward
0 new messages