Reputation: 673
I am encountering a very weird issue on visual studio code when i try to import packages.
import (
"net/http"
"github.com/gorilla/mux"
)
I get the error
cannot find package "github.com/gorilla/mux" in any of:
/usr/local/go/src/github.com/gorilla/mux (from $GOROOT)
/user/chirrut/go/src/github.com/gorilla/mux (from $GOPATH)
however when i run go build from the terminal, I don't get any error. also note that the GOPATH is set to /home/chirrut/go instead of /user/chirrut/go I ran echo on terminal, and the vscode integrated terminal and both returns me the correct path.
$ echo $GOPATH
/home/chirrut/go
Somehow, somewhere VSCode is getting the GOPATH value as /user/chirrut/go instead. anyone have any idea where else is the GOPATH variable read from in VS Code?
Upvotes: 1
Views: 2727
Reputation: 673
This seems like a problem with the ms-vscode.go plugin, if I disable it, the problem go away. and if i enable it, it comes back. Strangely I tried uninstalling it completely, and then reinstall it again, and the problem goes away.
Note: No, I did not make any changes to GOPATH at all since i first setup golang.
Upvotes: 1