My project consists of multiple go modules which I need to work on simultaneously. This is made easy by using the replace
directive in the go.mod file.
Further, in order to prevent this change from getting accidentally checked in, the go tools (starting with version 1.14) offer a -modfile
switch which lets me put the replace
directive in a go.local.mod
file instead. This is super convenient.
Unfortunately, I am unable to get Goland to pick up this go.local.mod
instead of go.mod
.
I have tried setting the GOMOD environment variable under Preferences -> Go -> Go Modules
to point to my go.local.mod
file. This did not do what I expected it to (which is to use the go.local.mod
file instead of go.mod
)
Not surprisingly, this did not work since GOMOD is supposed to be readonly (as pointed out to me in the comments).
For now I can go back to putting the replace directive in the go.mod file and using commit hooks to prevent accidental check-in (and Goland has some tooling to perform this check as well) However, it would be super convenient if Goland can recognize this new -modfile switch that go has added. Figured I would ask to make sure I'm not missing something obvious here.
Thanks!
At the moment, 2020.1.3 stable release, this is not supported. See the related issue for future updates on this.