go: cannot find main module, but found .git/config to create a module there, run: go mod
This problem occurred in a monorepo opened in VSCode. The repo has many services placed in isolated directories with respective
I realized from various sources that the problem is from two places:
- Move the mono repo under
- 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"
Do not add any other variable that affects
gopls such as
Written with StackEdit.