Update: Changed ${workspaceRoot} to ${workspaceRoot}/project_folder to get it to work.
I am just starting to learning Go and want to run it from Visual Studio Code.
I have this simple program:
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
}
I installed the Go extension from the marketplace: https://marketplace.visualstudio.com/items?itemName=lukehoban.Go
I also got the Delve debugger from here using go get: https://github.com/derekparker/delve
To try and run the code, I do this in Visual Studio Code:
- I click on my file with the above code
main.go - Go to the
Debugtab - Click
Launch(after generating thelaunch.jsonfile)
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}",
"env": {},
"args": []
}
]
}
Finally, I get this error:
can't load package: package github.com/mo: no buildable Go source files in C:\Users\Fazil\Documents\Workspace\Go\src\github.com\mo
exit status 1
Am I supposed to include something else? Any help would be appreciated, thank you!
${workspaceRoot}to${workspaceRoot}/folder. Thank you both, however. I was able to learn how to compile from command line and more about the environment variables for Go.