User12547645
User12547645

Reputation: 8447

Unable to automatically install go extensions in vscode

I am getting started with Go and would like to use Visual Studio Code for editing. I successfully installed go on my Ubuntu Computer.

My GOPATH (go env) is set to the same value as go.gopath in settings.json. If I run Go: Current GOPATH it outputs the correct path.

However, I am not able to install the go extensions. If I click on Install all I get output similar to this:

Installing 1 tool at home/jan/go/bin
  dlv

Installing github.com/go-delve/delve/cmd/dlv FAILED

1 tools failed to install.

dlv:
Error: Command failed: /snap/bin/go get -u -v github.com/go-delve/delve/cmd/dlv

I seem to be able to just install packages manually with /snap/bin/go get -u -v github.com/go-delve/delve/cmd/dlv. The command runs without errors, but VSCode seems to be unable to find dlv.

My settings.json:

{
    "terminal.integrated.rendererType": "dom",
    "go.useLanguageServer": true,
    "go.formatTool": "gofmt",
    "go.lintOnSave": "file",
    "go.vetOnSave": "package",
    "go.buildOnSave": "package",
    "go.lintTool": "golint",
    "go.gopath": "home/jan/go"
}

I have git installed on my computer. It works without a problem.

Upvotes: 3

Views: 6672

Answers (1)

Michael Hampton
Michael Hampton

Reputation: 9980

Your GOPATH is not set correctly in settings.json.

    "go.gopath": "home/jan/go"

This path is relative, and so it would be appended to whatever your working directory is, with the obvious result of not being able to find the path as it won't exist.

You can either set it correctly, or delete it and the GOPATH environment variable will be used. (I run it this way.)

    "go.gopath": "/home/jan/go"

Upvotes: 4

Related Questions