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:
main.go
Debug
tabLaunch
(after generating the launch.json
file)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!
I know you've already got it working by changing your working folder to the actual project folder, but here's the clue that should have helped
can't load package: package github.com/mo
github.com/mo is your username, not the project folder - Go is trying to run one folder up. You should always see github.com/mo/PROJECT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With