title: Goland: How to use a custom modfile instead of go.mod?
body: <p>My project consists of multiple go modules which I need to work on simultaneously. This is made easy by using the <code>replace</code> directive in the go.mod file.</p>
  
  <p>Further, in order to prevent this change from getting accidentally checked in, the go tools (starting with version 1.14) offer a <code>-modfile</code> switch which lets me put the <code>replace</code> directive in a <code>go.local.mod</code> file instead. This is super convenient.</p>
  
  <p><strong>Unfortunately, I am unable to get Goland to pick up this <code>go.local.mod</code> instead of <code>go.mod</code>.</strong></p>
  
  <p>I have tried setting the GOMOD environment variable under <code>Preferences -&gt; Go -&gt; Go Modules</code> to point to my <code>go.local.mod</code> file. This did not do what I expected it to (which is to use the <code>go.local.mod</code> file instead of <code>go.mod</code>)
  Not surprisingly, this did not work since GOMOD is supposed to be readonly (as pointed out to me in the comments). </p>
  
  <p>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.</p>
  
  <p>Thanks!</p>