automatically insert system's go version in go.mod

Sorry i'm very new to Golang and Goland IDE, today I found out that if I enable Go Module(vgo) integration in the Preferences, the IDE will automatically insert my system's go version at the end of go.mod file.

 

I'm wondering what does it mean for the project itself and is there any way to disable it ?

Thanks for the help

0
正式评论

It's not IDE who inserts it, it's Go itself.

No, you cannot disable it. See details here: https://github.com/golang/go/issues/34842

 

 

According to this comment in the link above, it is possible to use `-mod=readonly` to disable side effects.

Please include this in a hotfix soon, as it is very difficult to work like that. 

0

> According to this comment in the link above, it is possible to use `-mod=readonly` to disable side effects.

No. See the link I gave. readonly mode won't prevent Go to insert go version as it's not a cosmetic change.

> Please include this in a hotfix soon, as it is very difficult to work like that. 

I won't as it won't help you
0
Avatar
Permanently deleted user

It's fine I just wanna know what cause the insertion, thanks for the help .

0

I'm running into this as a side effect of having a large (monorepo) project loaded with a mix of golang version projects in subtrees.

 

Is there a way to ensure `go list` gets run with a specific version for a given subdirectory? I think that'd likely avoid the problem in my case since the appropriate golang version would get used to run `go list` and no modifications should get made (or if they do I can safely check them in).

 

I tried creating golang modules in the project, but I don't see an option to tell a specific module to use a specific SDK version.

 

Since my golang SDK is 1.13 and I'm on macos, I've marked the 1.12 go.mod files as "locked" in finder. This causes an error in intellij's event log, which is a little annoying (though https://go-review.googlesource.com/c/go/+/211698/  seems to say 1.14 might be better).

 

But avoids a git diff that could impede my ability to rebase/switch-branches/etc

0

请先登录再写评论。