Setting Gopath in VS Code on Windows

Seriously how? What is the specific syntax and keywords I should put into the settings.json?

Here is what I have right now:

“go.gopath”: “C:\TDM-GCC-64\bin;”

Whenever I execute, it always returns this error:

“process_begin: CreateProcess(NULL, env GO111MODULE=on go run build/ci.go install ./cmd/quai, …) failed.
make (e=2): The system cannot find the file specified.”

How must it be configured so it will work? What must the syntax be? What folder specifically should I make it point to with regards to the project (spread across many folders) I want to work on? I had this working just fine on LiteIDE so I suspect it may be a problem peculiar to VS Code.

This is a very general question about getting Go running in VS Code on Windows. It doesn’t depend on anything particular in my code, save that it’s a typical programming project with the files spread across a number of folders, albeit they are all inside its own folder so it’s organized.

Hi @reallyfitguy,

In general, unless you use a pre-Modules version of Go, you do not need to set GOPATH anymore. The single-workspace philosophy is a thing of the past, and a workspace is wherever a go.mod file is.

What happens if you do not set GOPATH inside VSC at all? The Go extension should be able to pick up the paths of your Go installation without any custom configuration.

1 Like

Even though you usually do not need the gopath anymore, you need to escape the backslashes using a backslash. That’s how JSON works.

Alas I should’ve checked it was the most recent string I had set. We are way past the needing to escape backslashes.

It is possible the problem has to do with the code itself, which I am now finding hasn’t really been tested on my setup. So who knows. After several more hours I did manage to track down the page that actually documents the keywords to use in the settings, but let’s say it’s very well hidden.

The documentation could really be cleaned up. Also, it’s very nice that the people who wrote golang are such geniuses you shouldn’t need to set gopath, but for my purposes, which were not anticipated by said geniuses, I do. So it’s not helpful to be told for the umpteenth time I shouldn’t need to. Maybe if that’s the case I should abandon golang entirely. The documentation manages to be worse than stackoverflow, and that’s quite an achievement.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.