Go failing - expected 'package', found 'EOF'

前端 未结 10 2133
感情败类
感情败类 2021-02-02 07:33

I\'ve been having a hard time trying to execute a simple golang program in a virtual machine powered by vagrant. These are the relevant fields of my go env:

10条回答
  •  北恋
    北恋 (楼主)
    2021-02-02 08:30

    For me, this also happened using Atom + Go Plus + Terminal Plus. The problem was that leading bracket was not on the "correct" line.

    NOTE: Go Plus warns about syntax upon save, but I had imported this file after creating it locally with VIM, so I was never presented with the lint errors...

    Error:

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

    Correct:

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

提交回复
热议问题