Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gorename not working: "Rename failed: gorename: can't find package containing"

When trying to change the symbols, VSCode throws the following error:

"Rename failed: gorename: can't find package containing /home/hume/projects/go/main.go"

vscode 1.22.2 x64

go version go1.10.1 linux/amd64

go env GOPATH /home/hume/projects/go

My settings.json is as follows:

{
      "go.toolsGopath": "/home/hume/gotools"
    , "go.autocompleteUnimportedPackages": true
    , "go.inferGopath": true
    , "go.formatTool": "gofmt"
    , "go.vetFlags": [
        "/src"
       ]
}

Thanks.

like image 895
Hume Avatar asked Apr 25 '18 20:04

Hume


1 Answers

You can switch to using gpls, the official Go language server. Besides other featured renaming symbols works perfectly regardless of any package structure.

In VSC open Preferences, Settings, and activate go.useLanguageServer. After installing gpls you are ready to go.

like image 155
iltempo Avatar answered Oct 01 '22 10:10

iltempo