I have a go program with two go files - the main and the called function. I want to run it under vs code. All the discussions I have found on the Internet deal with complex use cases that I cannot map to my simple situation. How can I prepare vs code to run my program. I should add that I have read many postings about the go ecosystem and I don’t understand any of them. What does GOPATH do? What does GOROOT do? Should I mess with them?
Which Go version do you use? Do you use
If all is set as it should, I right click on the
main.go in VS Code and select “Open in integrated terminal”. Then
go build and start using
./main (may differ depending on how you named things)
“go build” results in "C:<path>\build does not exist
Will this procedure enable it to run under the debugger or merely run it from the command line
go.mod results in not found. What is the correct command, is it “go mod” what are the arguments? I’m sorry but I have been struggling for hours and every bit of information is written for people who are already experts
Which version of Go do you use?
go version in the terminal
go version go1.19.2 darwin/amd64
go version go1.19.4 windows/amd64
Do you see any go.mod file?
If not try
go mod init go mod tidy //and then (right click on main.go and select this as path in VS Code Terminal) go build ./main
What problem specifically are you running in to? Have you tried this VSCode-specific guide to getting up and running?
It looks like you have Go installed as well as VSCode, so you can skip to step 3 and try it from there.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.