Member-only story

--

go: cannot find main module, but found .git config to create a module there, run: go mod

This problem occurred in a monorepo in VSCode. The repo has many services placed in isolated directories with their respective go.mod files.

I realized from various sources that the solution has two parts:

  1. Move the mono repo under $GOPATH/src. This solves many problems including ctags code navigation.
  2. The ~/.zshrc or ~/.bashrc must be as follows:
export GOPATH=$HOME/go/ export GOROOT=/usr/local/go  export PATH="$GOROOT/bin:$PATH" export PATH="$PATH:$GOPATH/bin"

3. Do not add any other variable that affects gopls such as GO111MODULE=on.

--

--

Simplify Complexity
Simplify Complexity

Written by Simplify Complexity

Golang, Distributed Systems, File Systems, Python, C/C++, Linux

No responses yet