E:\goapp
是我的GOPATH目录
分别建立了2个文件:
hello.go
// hello
package main
import "fmt"
func main() {
fmt.Println("Hello World! 你好,世界!")
}
sandbox.go
// sandbox
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println("Welcome to the playground!")
fmt.Println("The time is ", time.Now())
}
在liteide运行BR的时候报错了:main redeclared in this block previous declaration at .\hello.go:6
解决方案:在分别建立两个文件夹hello和sandbox,把文件放进去,再次BR两个文件,就没问题了。
原因是:同一个目录下面不能有个多 package main