From one day to the next I can't manage to debug a project where everything worked perfectly before. I'm sure I haven't changed anything about the project or its settings during this time. All I did was work on another project in the same IDE (VS Code).
The actual error in VS Code:
dbInteraction.go:8:2: cannot find package "github.com/go-sql-driver/mysql" in any of:
C:\Go\src\github.com\go-sql-driver\mysql (from $GOROOT)
c:\Users\Mani\Documents\Programmier Projekte\PRJCTNAME\src\github.com\go-sql-driver\mysql (from $GOPATH)
main.go:8:2: cannot find package "github.com/gorilla/mux" in any of:
C:\Go\src\github.com\gorilla\mux (from $GOROOT)
c:\Users\Mani\Documents\Programmier Projekte\PRJCTNAME\src\github.com\gorilla\mux (from $GOPATH)
exit status 1
Process exiting with code: 1
Checking the environment variables:
C:\Users\Mani>echo %GOPATH%
C:\Users\Mani\go
C:\Users\Mani>echo %GOROOT%
C:\Go\
As you can see, my environment variables are set as desired and the $GOPATH in the debug output does not match this path; in contract it is the actual path of my go sources for this project.
When i build the project over the command line with go build
(in the project directory) it works perfectly. That gives me the suspicion that VS Code is responsible for the problem.
The user settings and workspace settings in VS Code are both empty. Also empty is the project specific VS-Code settings.go
and the launch.go
has not changed from the default.
EDIT 1: If i remember correctly, i think I switched from VS Code 32bit
to VS Code 64bit
in between.
EDIT 2: After setting the env parameter in the launch.json I am able to debug the program again but now i do not get any output in the debug console.
If you're using the vscode-go extension, try changing the
go.gopath
setting as described on the Microsoft vscode-go wiki:I initially had problems with Visual Studio Code recognising my gopath, and this fixed it.