Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No buildable Go source files in folder

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 Debug tab
  • Click Launch (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!

like image 364
o.o Avatar asked Nov 09 '22 14:11

o.o


1 Answers

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

like image 115
Sudhir Jonathan Avatar answered Nov 15 '22 08:11

Sudhir Jonathan