Zeinab Abbasimazar
Zeinab Abbasimazar

Reputation: 10469

main packages in go 1.18.1 built-in libraries

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:

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.

Upvotes: 3

Views: 4099

Answers (1)

VonC
VonC

Reputation: 1328332

This was reported recently (Apr. 2022) (link in Chinese)

https://img-blog.csdnimg.cn/d93c6e9fb3584a00a52bf1949da1ee02.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAS2lt6YeRNg==,size_20,color_FFFFFF,t_70,g_se,x_16

The translation of the relevant comment is:

The reason for the above error: Your Go language version has been upgraded, and the IDE version is too old to support it.

For example, in my case, Go was upgraded to 1.18, and Goland was not upgraded.

So make sure your IDE (GoLand or VSCode) is fully updated (with, for VSCode, the latest gopls).

Upvotes: 5

Related Questions