Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: support finding generic interface implementations #66524

Closed
benz9527 opened this issue Mar 22, 2024 · 2 comments
Closed

x/tools/gopls: support finding generic interface implementations #66524

benz9527 opened this issue Mar 22, 2024 · 2 comments
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@benz9527
Copy link

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.

    • go version go1.22.0 windows/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

         Build info
          ----------
          golang.org/x/tools/gopls v0.15.2
              golang.org/x/tools/gopls@v0.15.2 h1:4JKt4inO8JaFW3l/Fh9X1k/5JQn+iUOpdc4/Lpi0mOs=
              github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
              github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
              golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
              golang.org/x/mod@v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
              golang.org/x/sync@v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
              golang.org/x/sys@v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
              golang.org/x/telemetry@v0.0.0-20240209200032-7b892fcb8a78 h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4=
              golang.org/x/text@v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
              golang.org/x/tools@v0.18.1-0.20240311201521-78fbdeb61842 h1:No0LMXYFkp3j4oEsPdtY8LUQz33gu79Rm9DE+izMeGQ=
              golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU=
              honnef.co/go/tools@v0.4.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8=
              mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
              mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
          go: go1.22.0
    
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

       1.87.2
        863d2581ecda6849923a2118d93a088b0745d9d6
        x64
    
  • Check your installed extensions to get the version of the VS Code Go extension

    • image
      • image
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

        # Tools Configuration
    
    
        ## Environment
        
        GOBIN: undefined
        toolsGopath: 
        gopath: D:\Ben-Projs\Go\GoPath
        GOROOT: D:\Ben-Env\Go\go1.22.0
        PATH: C:\Users\BenZh\AppData\Local\cloud-code\installer\google-cloud-sdk\bin;D:\Ben-Env\Go\go1.22.0\bin;D:\Ben-Env\Java\bin;D:\Ben-Env\Python3\Scripts\;D:\Ben-Env\Python3\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Ben-Env\Graphviz\bin;D:\Ben-Env\MSYS2\mingw64\bin;D:\Ben\AOMEI\AOMEI Backupper\6.9.1;C:\Program Files\dotnet\;D:\Ben-Env\NodeJs\;C:\ProgramData\chocolatey\bin;D:\Ben-Env\Yarn\bin\;D:\Ben-Env\Git\cmd;D:\Ben\StrawberryPerl\c\bin;D:\Ben\StrawberryPerl\perl\site\bin;D:\Ben\StrawberryPerl\perl\bin;C:\Users\BenZh\AppData\Local\Microsoft\WindowsApps;D:\Ben-Ideas\DataGrip 2022.2\bin;D:\Ben-Ideas\GoLand 2022.1.4\bin;D:\Ben-Env\Git\bin;D:\Ben-Env\Graphviz\bin;D:\Ben-Projs\Go\GoPath\bin;D:\Ben-Env\MSYS2\mingw64\bin;D:\Ben-Ideas\Microsoft VS Code\bin;C:\Users\BenZh\AppData\Local\Microsoft\WindowsApps;C:\Users\BenZh\AppData\Local\JetBrains\Toolbox\scripts;C:\Users\BenZh\AppData\Roaming\npm;D:\Ben-Env\Yarn\bin;D:\Ben-Ideas\GoLand 2023.3.3\bin;;;C:\Users\BenZh\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin
        PATH (vscode launched with): D:\Ben-Env\Java\bin;D:\Ben-Env\Python3\Scripts\;D:\Ben-Env\Python3\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Ben-Env\Graphviz\bin;D:\Ben-Env\MSYS2\mingw64\bin;D:\Ben\AOMEI\AOMEI Backupper\6.9.1;C:\Program Files\dotnet\;D:\Ben-Env\NodeJs\;C:\ProgramData\chocolatey\bin;D:\Ben-Env\Yarn\bin\;D:\Ben-Env\Git\cmd;D:\Ben\StrawberryPerl\c\bin;D:\Ben\StrawberryPerl\perl\site\bin;D:\Ben\StrawberryPerl\perl\bin;C:\Users\BenZh\AppData\Local\Microsoft\WindowsApps;D:\Ben-Ideas\DataGrip 2022.2\bin;D:\Ben-Ideas\GoLand 2022.1.4\bin;D:\Ben-Env\Git\bin;D:\Ben-Env\Graphviz\bin;D:\Ben-Projs\Go\GoPath\bin;D:\Ben-Env\MSYS2\mingw64\bin;D:\Ben-Ideas\Microsoft VS Code\bin;C:\Users\BenZh\AppData\Local\Microsoft\WindowsApps;C:\Users\BenZh\AppData\Local\JetBrains\Toolbox\scripts;C:\Users\BenZh\AppData\Roaming\npm;D:\Ben-Env\Yarn\bin;D:\Ben-Ideas\GoLand 2023.3.3\bin;;D:\Ben-Env\Go\go1.22.0\bin;
        
        ## Tools
        
            go:	D:\Ben-Env\Go\go1.22.0\bin\go.exe: go version go1.22.0 windows/amd64
        
            gopls:	D:\Ben-Projs\Go\GoPath\bin\gopls.exe	(version: v0.15.2 built with go: go1.22.0)
            gotests:	D:\Ben-Projs\Go\GoPath\bin\gotests.exe	(version: v1.6.0 built with go: go1.22.0)
            gomodifytags:	D:\Ben-Projs\Go\GoPath\bin\gomodifytags.exe	(version: v1.16.0 built with go: go1.22.0)
            impl:	D:\Ben-Projs\Go\GoPath\bin\impl.exe	(version: v1.1.0 built with go: go1.22.0)
            goplay:	D:\Ben-Projs\Go\GoPath\bin\goplay.exe	(version: v1.0.0 built with go: go1.22.0)
            dlv:	D:\Ben-Projs\Go\GoPath\bin\dlv.exe	(version: v1.22.1 built with go: go1.22.0)
            golangci-lint:	D:\Ben-Projs\Go\GoPath\bin\golangci-lint.exe	(version: v1.57.1 built with go: go1.22.0)
        
        ## Go env
        
        Workspace Folder (xboot): d:\Ben-Projs\Go\xboot
        
            set GO111MODULE=
            set GOARCH=amd64
            set GOBIN=
            set GOCACHE=C:\Users\BenZh\AppData\Local\go-build
            set GOENV=C:\Users\BenZh\AppData\Roaming\go\env
            set GOEXE=.exe
            set GOEXPERIMENT=
            set GOFLAGS=-mod=vendor
            set GOHOSTARCH=amd64
            set GOHOSTOS=windows
            set GOINSECURE=
            set GOMODCACHE=D:\Ben-Projs\Go\GoPath\pkg\mod
            set GONOPROXY=
            set GONOSUMDB=
            set GOOS=windows
            set GOPATH=D:\Ben-Projs\Go\GoPath
            set GOPRIVATE=
            set GOPROXY=https://proxy.golang.org,direct
            set GOROOT=D:\Ben-Env\Go\go1.22.0
            set GOSUMDB=sum.golang.org
            set GOTMPDIR=
            set GOTOOLCHAIN=auto
            set GOTOOLDIR=D:\Ben-Env\Go\go1.22.0\pkg\tool\windows_amd64
            set GOVCS=
            set GOVERSION=go1.22.0
            set GCCGO=gccgo
            set GOAMD64=v1
            set AR=ar
            set CC=gcc
            set CXX=g++
            set CGO_ENABLED=1
            set GOMOD=d:\Ben-Projs\Go\xboot\go.mod
            set GOWORK=
            set CGO_CFLAGS=-O2 -g
            set CGO_CPPFLAGS=
            set CGO_CXXFLAGS=-O2 -g
            set CGO_FFLAGS=-O2 -g
            set CGO_LDFLAGS=-O2 -g
            set PKG_CONFIG=pkg-config
            set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\BenZh\AppData\Local\Temp\go-build2291266762=/tmp/go-build -gno-record-gcc-switches
    

Share the Go related settings you have added/edited

{
  "go.lintTool": "golangci-lint",
  "window.zoomLevel": 1,
  "go.inferGopath": true,
  "go.lintOnSave": "file",
  "go.vetOnSave": "package",
  "go.goroot": "D:\\Ben-Env\\Go\\go1.22.0",
  "go.gopath": "D:\\Ben-Projs\\Go\\GoPath",
  "go.testTimeout": "120s",
  "go.delveConfig": {
    "logOutput": "debugger",
    "showLog": false,
    "showGlobalVariables": false,
    "debugAdapter": "dlv-dap",
    "dlvFlags": ["--headless", "--log", "--api-version=2"]
  },
  "go.coverOnSave": true,
  "go.coverageDecorator": {
    "type": "gutter",
    "coveredHighlightColor": "rgba(64,128,128,0.5)",
    "uncoveredHighlightColor": "rgba(128,64,64,0.25)",
    "coveredGutterStyle": "blockgreen",
    "uncoveredGutterStyle": "blockred"
  },
  "go.coverOnSingleTest": true,
  "go.buildTags": "windows",
  "go.buildFlags": [],
  "go.toolsEnvVars": {
    "GOFLAGS": "-mod=vendor"
  },
  "go.showWelcome": true,
  "gopls": {
    "build.buildFlags": ["-tags=windows"]
  }
}

Describe the bug

image

When I tried to findout how many implementations of this interface, I got "no impl" result.

image

image

image

image

Actually, I have some implementations for this generic interface.

image

image

image

image

Steps to reproduce the behavior:

Please check bug description pictures.

Screenshots or recordings

Please check bug description pictures.

@suzmue
Copy link
Contributor

suzmue commented Mar 25, 2024

Simplified repro:

main.go:

package main

import "fmt"

type A[T any] interface {
	Skip() T
}

type B struct{}

func (b *B) Skip() string {
	return "hello"
}

func main() {
	var x A[string] = &B{}
	fmt.Println(x.Skip())
}

@suzmue suzmue changed the title It seems vscode-go unable to find the generic interface implementations correctly. x/tools/gopls: support finding generic interface implementations Mar 25, 2024
@suzmue suzmue transferred this issue from golang/vscode-go Mar 25, 2024
@suzmue suzmue added this to the gopls/backlog milestone Mar 25, 2024
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Mar 25, 2024
@suzmue
Copy link
Contributor

suzmue commented Mar 28, 2024

This is actually a duplicate of #59224, so will close in favor of that one.

@suzmue suzmue closed this as completed Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants