fatih / vim-go

Go development plugin for Vim
https://www.patreon.com/bhcleek
Other
15.98k stars 1.45k forks source link

can't :GoImpl in workspace mode, unrecognized interface: xxx #3560

Closed kirito41dd closed 1 year ago

kirito41dd commented 1 year ago

tree:

go.work
/package1/go.mod
/package1/...
/package2/go.mod
/package2/...

:GoImpl p xx(package1) package2.xxInterface

unrecognized interface: package2.xxInterface

bhcleek commented 1 year ago

Please provide the information requested in the issue template that's used when creating a new issue.

However, assuming that you're using a relatively modern version of Go, here are some things for you to know and to check:

kirito41dd commented 1 year ago

What did you do? (required: The issue will be closed when not provided)

i use :GoImpl in a go.work project

What did you expect to happen?

impl the interface

What happened instead?

has error unrecognized interface: package2.xxInterface

Configuration (MUST fill this out):

return {
    "fatih/vim-go",
    build = ':GoInstallBinaries' -- if you need to install/update all binaries
}

vim-go version:

● vim-go 2.01ms  start
        e3008d9 update CHANGELOG.md for #3538 (13 days ago)

vimrc you used to reproduce:

vimrc ```vim ```

Vim version (first three lines from :version):

nvim 0.9.1

Go version (go version):

GOVERSION="go1.19.1"

Go environment

go env Output:


GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/x/Library/Caches/go-build"
GOENV="/Users/x/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/x/go/pkg/mod"
GOOS="darwin"
GOPATH="/Users/x/go"
GOMOD="/Users/x/work/go.mod"
GOWORK="/Users/x/work/xxx/go.work"

gopls version

gopls version Output:

golang.org/x/tools/gopls v0.12.1
    golang.org/x/tools/gopls@v0.12.2 h1:s4mznBqCHVHeuTYjxGYJhsW3Wp4FYon8YAqiJlwlpTY=
kirito41dd commented 1 year ago

when i run: ➜ impl -dir package1/ 'es *package1.xxx' package2.Interface

there are nothing output and nothing change

maybe not support yet

bhcleek commented 1 year ago

This all works for me. I'm able to generate the implementation using vim-go and using impl on the commandline.

Perhaps you need to upgrade impl with :GoUpdateBinaries impl?

kirito41dd commented 1 year ago

after :GoUpdateBinaries impl, it's ok