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

Cannot jump to the interface implementation, while can jump to the references and definitions #3626

Closed
longkui-clown opened this issue Dec 10, 2024 · 2 comments
Milestone

Comments

@longkui-clown
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.21.13 windows/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

    • golang.org/x/tools/gopls v0.16.2
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • 1.80.1
  • Check your installed extensions to get the version of the VS Code Go extension

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

    Tools Configuration

      ## Environment
    
      GOBIN: undefined
      toolsGopath: 
      gopath: C:\Users\long\go
      GOROOT: C:\Program Files\Go
      PATH: C:\Python312\Scripts\;C:\Python312\;C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\dotnet\;C:\Program Files\Microsoft VS Code\bin;C:\tinygo0.33.0.windows-amd64\tinygo\bin;C:\binaryen-version_117-x86_64-windows\binaryen-version_117\bin;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;C:\Program Files\Go\bin;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\protoc-29.0-rc-3-win64\bin;C:\protoc-gen-go.v1.35.2.windows.amd64;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Users\long\.cargo\bin;C:\Users\long\AppData\Local\Microsoft\WindowsApps;;C:\Program Files\JetBrains\IntelliJ IDEA 2023.1\bin;;C:\Users\long\go\bin;C:\Users\long\AppData\Roaming\npm
    
      ## Tools
    
      	go:	C:\Program Files\Go\bin\go.exe: go version go1.21.13 windows/amd64
    
      	gopls:	C:\Users\long\go\bin\gopls.exe	(version: v0.16.2 built with go: go1.21.13)
      	gotests:	C:\Users\long\go\bin\gotests.exe	(version: v1.6.0 built with go: go1.21.13)
      	gomodifytags:	C:\Users\long\go\bin\gomodifytags.exe	(version: v1.17.0 built with go: go1.21.13)
      	impl:	C:\Users\long\go\bin\impl.exe	(version: v1.4.0 built with go: go1.21.13)
      	goplay:	C:\Users\long\go\bin\goplay.exe	(version: v1.0.0 built with go: go1.21.13)
      	dlv:	C:\Users\long\go\bin\dlv.exe	(version: v1.23.1 built with go: go1.21.13)
      	staticcheck:	C:\Users\long\go\bin\staticcheck.exe	(version: v0.5.1 built with go: go1.22.8)
    
      ## Go env
    
      Workspace Folder (goose): d:\Projects\EYS\server\goose
    
      	set GO111MODULE=auto
      	set GOARCH=amd64
      	set GOBIN=
      	set GOCACHE=C:\Users\long\AppData\Local\go-build
      	set GOENV=C:\Users\long\AppData\Roaming\go\env
      	set GOEXE=.exe
      	set GOEXPERIMENT=
      	set GOFLAGS=
      	set GOHOSTARCH=amd64
      	set GOHOSTOS=windows
      	set GOINSECURE=
      	set GOMODCACHE=C:\Users\long\go\pkg\mod
      	set GONOPROXY=
      	set GONOSUMDB=
      	set GOOS=windows
      	set GOPATH=C:\Users\long\go
      	set GOPRIVATE=
      	set GOPROXY=https://goproxy.cn,direct
      	set GOROOT=C:\Program Files\Go
      	set GOSUMDB=sum.golang.org
      	set GOTMPDIR=
      	set GOTOOLCHAIN=auto
      	set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
      	set GOVCS=
      	set GOVERSION=go1.21.13
      	set GCCGO=gccgo
      	set GOAMD64=v1
      	set AR=ar
      	set CC=gcc
      	set CXX=g++
      	set CGO_ENABLED=0
      	set GOMOD=d:\Projects\EYS\server\goose\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 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\long\AppData\Local\Temp\go-build845451594=/tmp/go-build -gno-record-gcc-switches
      	
      Workspace Folder (host): d:\Projects\EYS\server\host
    
      	set GO111MODULE=auto
      	set GOARCH=amd64
      	set GOBIN=
      	set GOCACHE=C:\Users\long\AppData\Local\go-build
      	set GOENV=C:\Users\long\AppData\Roaming\go\env
      	set GOEXE=.exe
      	set GOEXPERIMENT=
      	set GOFLAGS=
      	set GOHOSTARCH=amd64
      	set GOHOSTOS=windows
      	set GOINSECURE=
      	set GOMODCACHE=C:\Users\long\go\pkg\mod
      	set GONOPROXY=
      	set GONOSUMDB=
      	set GOOS=windows
      	set GOPATH=C:\Users\long\go
      	set GOPRIVATE=
      	set GOPROXY=https://goproxy.cn,direct
      	set GOROOT=C:\Program Files\Go
      	set GOSUMDB=sum.golang.org
      	set GOTMPDIR=
      	set GOTOOLCHAIN=auto
      	set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
      	set GOVCS=
      	set GOVERSION=go1.21.13
      	set GCCGO=gccgo
      	set GOAMD64=v1
      	set AR=ar
      	set CC=gcc
      	set CXX=g++
      	set CGO_ENABLED=0
      	set GOMOD=
      	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 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\long\AppData\Local\Temp\go-build1329300920=/tmp/go-build -gno-record-gcc-switches
    

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

// Tags and options configured here will be used by the Add Tags command to add tags to struct fields. If promptForTags is true, then user will be prompted for tags and options. By default, json tags are added.
	"go.addTags": {
		"tags": "json",
		"options": "json=omitempty",
		"promptForTags": false,
		"transform": "snakecase",
		"template": ""
	},

	// Alternate tools or alternate paths for the same tools used by the Go extension. Provide either absolute path or the name of the binary in GOPATH/bin, GOROOT/bin or PATH. Useful when you want to use wrapper script for the Go tools.
	"go.alternateTools": {},

	// Flags to `go build`/`go test` used during build-on-save or running tests. (e.g. ["-ldflags='-s'"]) This is propagated to the language server if `gopls.build.buildFlags` is not specified.
	"go.buildFlags": [],

	// Enable the Go language server (`go.useLanguageServer`) to diagnose compile errors.
	// Compiles code on file save using 'go build' or 'go test -c'. Not applicable when using the language server.
	"go.buildOnSave": "package",

	// The Go build tags to use for all commands, that support a `-tags '...'` argument. When running tests, go.testTags will be used instead if it was set. This is propagated to the language server if `gopls.build.buildFlags` is not specified.
	"go.buildTags": "",

	// This option lets you choose the way to display code coverage. Choose either to highlight the complete line or to show a decorator in the gutter. You can customize the colors and borders for the former and the style for the latter.
	"go.coverageDecorator": {
		"type": "highlight",
		"coveredHighlightColor": "rgba(64,128,128,0.5)",
		"uncoveredHighlightColor": "rgba(128,64,64,0.25)",
		"coveredBorderColor": "rgba(64,128,128,0.5)",
		"uncoveredBorderColor": "rgba(128,64,64,0.25)",
		"coveredGutterStyle": "blockblue",
		"uncoveredGutterStyle": "slashyellow"
	},

	// Use these options to control whether only covered or only uncovered code or both should be highlighted after running test coverage
	"go.coverageOptions": "showBothCoveredAndUncoveredCode",

	// When generating code coverage, the value for -covermode. 'default' is the default value chosen by the 'go test' command.
	"go.coverMode": "default",

	// If true, runs 'go test -coverprofile' on save and shows test coverage.
	"go.coverOnSave": false,

	// If true, shows test coverage when Go: Test Function at cursor command is run.
	"go.coverOnSingleTest": false,

	// If true, shows test coverage when Go: Test Single File command is run.
	"go.coverOnSingleTestFile": false,

	// If true, shows test coverage when Go: Test Package command is run.
	"go.coverOnTestPackage": true,

	// When generating code coverage, should counts be shown as --374--
	"go.coverShowCounts": false,

	// Delve settings that applies to all debugging sessions. Debug configuration in the launch.json file will override these values.
	"go.delveConfig": {},

	// (Experimental) vulncheck enables vulnerability scanning.
	// 
	//  - Imports: `"Imports"`: In Imports mode, `gopls` will report vulnerabilities that affect packages
	// directly and indirectly used by the analyzed main module.
	// 
	//  - Off: `"Off"`: Disable vulnerability analysis.
	// 
	"go.diagnostic.vulncheck": "Off",

	// If true, tests will not run concurrently. When a new test run is started, the previous will be cancelled.
	"go.disableConcurrentTests": false,

	// Experimental Feature: Enable/Disable entries from the context menu in the editor.
	"go.editorContextMenuCommands": {
		"toggleTestFile": true,
		"addTags": true,
		"removeTags": false,
		"fillStruct": false,
		"testAtCursor": true,
		"testFile": false,
		"testPackage": false,
		"generateTestForFunction": true,
		"generateTestForFile": false,
		"generateTestForPackage": false,
		"addImport": true,
		"testCoverage": true,
		"playground": true,
		"debugTestAtCursor": true,
		"benchmarkAtCursor": false
	},

	// Feature level setting to enable/disable code lens for references and run/debug tests
	"go.enableCodeLens": {
		"runtest": true
	},

	// Flags to pass to format tool (e.g. ["-s"]). Not applicable when using the language server.
	"go.formatFlags": [],

	// When the language server is enabled and one of `default`/`gofmt`/`goimports`/`gofumpt` is chosen, the language server will handle formatting. If `custom` tool is selected, the extension will use the `customFormatter` tool in the `go.alternateTools` section.
	//  - default: If the language server is enabled, format via the language server, which already supports gofmt, goimports, goreturns, and gofumpt. Otherwise, goimports.
	//  - gofmt: Formats the file according to the standard Go style. (not applicable when the language server is enabled)
	//  - goimports: Organizes imports and formats the file with gofmt. (not applicable when the language server is enabled)
	//  - goformat: Configurable gofmt, see https://github.com/mbenkmann/goformat.
	//  - gofumpt: Stricter version of gofmt, see https://github.com/mvdan/gofumpt. . Use `gopls.format.gofumpt` instead)
	//  - custom: Formats using the custom tool specified as `customFormatter` in the `go.alternateTools` setting. The tool should take the input as STDIN and output the formatted code as STDOUT.
	"go.formatTool": "default",

	// Additional command line flags to pass to `gotests` for generating tests.
	"go.generateTestsFlags": [],

	// Specify GOPATH here to override the one that is set as environment variable. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true.
	"go.gopath": null,

	// Specifies the GOROOT to use when no environment variable is set.
	"go.goroot": null,

	// Infer GOPATH from the workspace root. This is ignored when using Go Modules.
	"go.inferGopath": false,

	// Enable/disable inlay hints for variable types in assign statements:
	// ```go
	// 	i/* int*/, j/* int*/ := 0, len(r)-1
	// ```
	"go.inlayHints.assignVariableTypes": false,

	// Enable/disable inlay hints for composite literal field names:
	// ```go
	// 	{/*in: */"Hello, world", /*want: */"dlrow ,olleH"}
	// ```
	"go.inlayHints.compositeLiteralFields": false,

	// Enable/disable inlay hints for composite literal types:
	// ```go
	// 	for _, c := range []struct {
	// 		in, want string
	// 	}{
	// 		/*struct{ in string; want string }*/{"Hello, world", "dlrow ,olleH"},
	// 	}
	// ```
	"go.inlayHints.compositeLiteralTypes": false,

	// Enable/disable inlay hints for constant values:
	// ```go
	// 	const (
	// 		KindNone   Kind = iota/* = 0*/
	// 		KindPrint/*  = 1*/
	// 		KindPrintf/* = 2*/
	// 		KindErrorf/* = 3*/
	// 	)
	// ```
	"go.inlayHints.constantValues": false,

	// Enable/disable inlay hints for implicit type parameters on generic functions:
	// ```go
	// 	myFoo/*[int, string]*/(1, "hello")
	// ```
	"go.inlayHints.functionTypeParameters": false,

	// Enable/disable inlay hints for parameter names:
	// ```go
	// 	parseInt(/* str: */ "123", /* radix: */ 8)
	// ```
	"go.inlayHints.parameterNames": false,

	// Enable/disable inlay hints for variable types in range statements:
	// ```go
	// 	for k/* int*/, v/* string*/ := range []string{} {
	// 		fmt.Println(k, v)
	// 	}
	// ```
	"go.inlayHints.rangeVariableTypes": false,

	// If true, then `-i` flag will be passed to `go build` everytime the code is compiled. Since Go 1.10, setting this may be unnecessary unless you are in GOPATH mode and do not use the language server.
	"go.installDependenciesWhenBuilding": false,

	// Flags like -rpc.trace and -logfile to be used while running the language server.
	"go.languageServerFlags": [],

	// Flags to pass to Lint tool (e.g. ["-min_confidence=.8"])
	"go.lintFlags": [],

	// Lints code on file save using the configured Lint tool. Options are 'file', 'package', 'workspace' or 'off'.
	//  - file: lint the current file on file saving
	//  - package: lint the current package on file saving
	//  - workspace: lint all the packages in the current workspace root folder on file saving
	//  - off: do not run lint automatically
	"go.lintOnSave": "package",

	// Specifies Lint tool name.
	"go.lintTool": "staticcheck",

	// This setting is deprecated. Use 'Developer: Set Log Level...' command to control logging level instead.
	// 
	"go.logging.level": "",

	// The flags configured here will be passed through to command `goplay`
	"go.playground": {
		"openbrowser": true,
		"share": true,
		"run": true
	},

	// Tags and options configured here will be used by the Remove Tags command to remove tags to struct fields. If promptForTags is true, then user will be prompted for tags and options. By default, all tags and options will be removed.
	"go.removeTags": {
		"tags": "",
		"options": "",
		"promptForTags": false
	},

	// Specifies whether to show the Welcome experience on first install
	"go.showWelcome": true,

	// Prompt for surveys, including the gopls survey and the Go developer survey.
	"go.survey.prompt": true,

	// enable the default go build/test task provider.
	"go.tasks.provideDefault": true,

	// Apply the Go & PATH environment variables used by the extension to all integrated terminals.
	"go.terminal.activateEnvironment": true,

	// Absolute path to a file containing environment variables definitions. File contents should be of the form key=value.
	"go.testEnvFile": null,

	// Environment variables that will be passed to the process that runs the Go tests
	"go.testEnvVars": {},

	// Run benchmarks when running all tests in a file or folder.
	"go.testExplorer.alwaysRunBenchmarks": false,

	// Concatenate all test log messages for a given location into a single message.
	"go.testExplorer.concatenateMessages": true,

	// Enable the Go test explorer
	"go.testExplorer.enable": true,

	// Present packages in the test explorer flat or nested.
	"go.testExplorer.packageDisplayMode": "flat",

	// Set the source location of dynamically discovered subtests to the location of the containing function. As a result, dynamically discovered subtests will be added to the gutter test widget of the containing function.
	"go.testExplorer.showDynamicSubtestsInEditor": false,

	// Open the test output terminal when a test run is started.
	"go.testExplorer.showOutput": true,

	// Flags to pass to `go test`. If null, then buildFlags will be used. This is not propagated to the language server.
	"go.testFlags": null,

	// Run 'go test' on save for current package. It is not advised to set this to `true` when you have Auto Save enabled.
	"go.testOnSave": false,

	// The Go build tags to use for when running tests. If null, then buildTags will be used.
	"go.testTags": null,

	// Specifies the timeout for go test in ParseDuration format.
	"go.testTimeout": "30s",

	// Environment variables that will be passed to the tools that run the Go tools (e.g. CGO_CFLAGS) and debuggee process launched by Delve. Format as string key:value pairs. When debugging, merged with `envFile` and `env` values with precedence `env` > `envFile` > `go.toolsEnvVars`.
	"go.toolsEnvVars": {},

	// Location to install the Go tools that the extension depends on if you don't want them in your GOPATH.
	"go.toolsGopath": null,

	// Automatically update the tools used by the extension, without prompting the user.
	"go.toolsManagement.autoUpdate": false,

	// Specify whether to prompt about new versions of Go and the Go tools (currently, only `gopls`) the extension depends on
	//  - proxy: keeps notified of new releases by checking the Go module proxy (GOPROXY)
	//  - local: checks only the minimum tools versions required by the extension
	//  - off: completely disables version check (not recommended)
	"go.toolsManagement.checkForUpdates": "proxy",

	// The path to the `go` binary used to install the Go tools. If it's empty, the same `go` binary chosen for the project will be used for tool installation.
	"go.toolsManagement.go": "",

	// Trace the communication between VS Code and the Go language server.
	"go.trace.server": "off",

	// Enable intellisense, code navigation, refactoring, formatting & diagnostics for Go. The features are powered by the Go language server "gopls".
	"go.useLanguageServer": true,

	// Flags to pass to `go tool vet` (e.g. ["-all", "-shadow"]). Not applicable when using the language server's diagnostics.
	"go.vetFlags": [],

	// Vets code on file save using 'go tool vet'. Not applicable when using the language server's diagnostics.
	//  - package: vet the current package on file saving
	//  - workspace: vet all the packages in the current workspace root folder on file saving
	//  - off: do not run vet automatically
	"go.vetOnSave": "package",

	// Configure the default Go language server ('gopls'). In most cases, configuring this section is unnecessary. See [the documentation](https://github.com/golang/tools/blob/master/gopls/doc/settings.md) for all available settings.
	"gopls": {},

Describe the bug

A clear and concise description of what the bug.

Cannot jump to the interface implementation, while can jump to the references and definitions

A clear and concise description of what you expected to happen.

I hope to be able to jump the implementation normally

Steps to reproduce the behavior:

  1. define a interface and define a base struct
type IMapStateMeetingHandler[STATE_T any] interface {
	OnStateMeetingTrigger(sceneState *dto.SceneState[STATE_T]) error
}

type mapStateMeetingBase[STATE_T any] struct{}

func (base mapStateMeetingBase[STATE_T]) OnStateMeetingTrigger(sceneState *dto.SceneState[STATE_T]) error {
	return nil

}
  1. define a struct with base struct, and rewrite the function
func (m *MapDetective) OnStateMeetingStart(sceneState *dto.SceneState[dto.StateDetective]) error {
	return nil
}
  1. and then can see this bug

Screenshots or recordings

20241210105246_rec_
image

@gopherbot gopherbot added this to the Untriaged milestone Dec 10, 2024
@findleyr
Copy link
Member

Thanks for this issue.

Coincidentally, @adonovan is currently implementing improved support for generic interface implements queries, so this should be fixed in [email protected] (https://go.dev/cl/634596).

I believe this is logically a dupe of https://go.dev/issue/59224.

@findleyr findleyr closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2024
@longkui-clown
Copy link
Author

thanks, i got it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants