Gorename不起作用:“重命名失败:gorename:找不到包含的软件包”

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.

VSCode uses gorename command-line tool to do rename. The tool supposes you are following the right package structure but it fails to find it. Create a src directory in %GOPATH%, i.e. create directory /home/hume/projects/go/src. Create another directory in src as the package directory and put main.go in the package directory. You need to add package declaration at main.go. Then the problem is resoved.