'VSCode Go Plugin : GOPATH vs GOMODCACHE
I use a custom location for GOMODCACHE (~/.gomodcache/) and GOPATH ~/project/go. This is to handle the errors from GOPLS while using the mono-repo approach of workspace.
When I do go get, the modules are downloaded to GOMODCACHE but, unable to see them in GOPATH. I use VSCode’s Go plugin. The plugin just looks for the list of modules from GOPATH and GOROOT. So, the plugin is unable to find the modules from GOMODCACHE and unable to provide suggestions on autocomplete.
Is there a way to get the modules into GOPATH instead of GOMODCACHE? Or Is there a way to make vscode to read the modules from GOMODCACHE instead of GOPATH?
Solution 1:[1]
It worked for me with the below steps :
- run
go mod initfor main.go which will generate go.mod file - run
go getfor required packages which will generate go.sum
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | benson23 |
