There are no built-in Go source files in the folder

Update : changed ${workspaceRoot} to ${workspaceRoot}/project_folder to make it work.


I'm just starting to learn 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 market: 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 to run the code, I do this in Visual Studio code:

  • I click on my file with the main.go code main.go
  • Go to the Debug tab
  • Click Launch (after creating 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 

Should I include something else? Any help would be appreciated, thanks!

+5
source share
1 answer

I know that you already have work by changing the working folder to the actual project folder, but here is the key that should have helped

 can't load package: package github.com/mo 

github.com/mo is your username, not your project folder - Go is trying to run one folder up. You should always see github.com/mo/PROJECT

+1
source

All Articles