GO 1.18.1内置库中的主要软件包
我正在尝试将项目的Golang版本从1.15
升级到1.18.1
。我更改了go.mod
的版本,并执行GO MOD TIDY
命令。
很奇怪的是,我在主文件中遇到了以下错误,该文件内部具有main
函数:
'main' collides with name declared in this package
net/http
and syscall
库>库发生。
net/http
在'/usr/local/go-1.1.18.1/src/net/http ;/usr/local/go-1.18.1/src/src/net/http'中找到了几个软件包[http,main]
syscall
在'/usr/local/go-1.1.18.1/src/syscall ;/usr/local/go-1.18.1/src/src/syscall'中找到了几个软件包[syscall,main]
当我检查警告时,
是正确的,并且两个库中都有主包。我应该使用替代库还是应该更改导入它们的方式?
编辑1:
这是一个IDE错误,我使用Goland。
I am trying to upgrade my project's golang version from 1.15
to 1.18.1
. I changed the version in go.mod
and executed go mod tidy
command.
Weird thing, I got following error in my main file which has a main
function inside itself:
'main' collides with name declared in this package
It happens for net/http
and syscall
libraries:
net/http
Found several packages [http, main] in '/usr/local/go-1.18.1/src/net/http;/usr/local/go-1.18.1/src/net/http'
syscall
Found several packages [syscall, main] in '/usr/local/go-1.18.1/src/syscall;/usr/local/go-1.18.1/src/syscall'
As I checked the warning was correct and there were main packages in both libraries.
Should I use an alternative library or should I change the way I import them?
Edit 1:
This is an IDE error and I use Goland.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是最近报道了(2022年4月)
这 href =“ https://i.sstatic.net/hpfwc.png” rel =“ nofollow noreferrer”>
相关的翻译评论是:
因此,请确保您的IDE(Goland或Vscode)已完全更新(对于vscode, gopls )。
This was reported recently (Apr. 2022) (link in Chinese)
The translation of the relevant comment is:
So make sure your IDE (GoLand or VSCode) is fully updated (with, for VSCode, the latest
gopls
).