-1

Backstory

I got this error amongst numerous others setting up a new virtual box LMDE5 on my new windows 11 pro computer. I haven't used windows in about 12 years, and the changes were crazy causing countless errors on Windows and LMDE5 Vbox. My last issue was this in vs code.

Error

go module packages.Load error: err: exit status 2: stderr: go: no such tool "compile": go list

My project directory structure

.
├── docker-compose.yaml
├── project.code-workspace
├── go.mod
├── go.sum
├── main.go
└── sub_packages
    ├── backend
    │   ├── folder1
    │   ├── folder2
    ├── api
    │   ├── handlers
    │   └── requests
    ├── entities
    ├── services
    └── utils

settings.json file

{
    // ...
    "go.goroot": "/usr/local/go",
    "go.gopath": "/home/user_name/go",
    // ...
}
codelinx
  • 107
  • 1
  • 1
  • 10

1 Answers1

1

Solution

Add the go tool dir ENV variable directly to VS Code settings.json to the settings to pickup the location of the folder .../linux_amd64 where compile was located.

settings.json file

{
    // ...
    "go.goroot": "/usr/local/go",
    "go.gopath": "/home/username/go",
    "go.alternateTools": {
        "GOTOOLDIR": "/usr/local/go/pkg/tool/linux_amd64"    
    },
    // ...
}
codelinx
  • 107
  • 1
  • 1
  • 10