学习go语言碰到的问题:main redeclared in this block

来源:互联网 发布:台风灾害数据网址 编辑:程序博客网 时间:2024/06/11 08:13

学习go语言碰到的问题:main redeclared in this block


E:\goapp

是我的GOPATH目录

分别建立了2个文件:

hello.go

// hellopackage mainimport "fmt"func main() {fmt.Println("Hello World! 你好,世界!")}

sandbox.go

// sandboxpackage mainimport ("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


原创粉丝点击