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: hover link is incorrect for embedded struct #40294

Closed
innerop opened this issue Jul 17, 2020 · 1 comment
Closed

x/tools/gopls: hover link is incorrect for embedded struct #40294

innerop opened this issue Jul 17, 2020 · 1 comment
Labels
FrozenDueToAge 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

@innerop
Copy link

innerop commented Jul 17, 2020

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

  • Run go version to get version of Go
    go version go1.14.3 darwin/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    1.47.2
  • Check your installed extensions to get the version of the VS Code Go extension
    v0.15.1
  • Run go env to get the go development environment details
    GO111MODULE=""
    GOARCH="amd64"
    GOBIN=""
    GOCACHE="/Users/marc/Library/Caches/go-build"
    GOENV="/Users/marc/Library/Application Support/go/env"
    GOEXE=""
    GOFLAGS=""
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOINSECURE=""
    GONOPROXY=""
    GONOSUMDB=""
    GOOS="darwin"
    GOPATH="/Users/marc/go"
    GOPRIVATE=""
    GOPROXY="https://proxy.golang.org,direct"
    GOROOT="/usr/local/Cellar/go/1.14.3/libexec"
    GOSUMDB="sum.golang.org"
    GOTMPDIR=""
    GOTOOLDIR="/usr/local/Cellar/go/1.14.3/libexec/pkg/tool/darwin_amd64"
    GCCGO="gccgo"
    AR="ar"
    CC="clang"
    CXX="clang++"
    CGO_ENABLED="1"
    GOMOD=""
    CGO_CFLAGS="-g -O2"
    CGO_CPPFLAGS=""
    CGO_CXXFLAGS="-g -O2"
    CGO_FFLAGS="-g -O2"
    CGO_LDFLAGS="-g -O2"
    PKG_CONFIG="pkg-config"
    GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/1q/jpdtk_3x6b53cjtmt4rxccsh0000gn/T/go-build578823030=/tmp/go-build -gno-record-gcc-switches -fno-common"

Share the Go related settings you have added/edited

None.

Describe the bug

Wrong type description in popover that leads to wrong/non-existent section of the docs

Steps to reproduce the behavior:

  1. Create this in xyz.go
package http

import (

	"github.com/gorilla/mux"
)

// Handler ..
type MyHandler struct {
	*mux.Router
}

func NewHandler() *MyHandler {
	h := &MyHandler{}

	h.HandleFunc("/api/v0/stream/{username}", h.handleStream).Methods("GET")

	return h
}
  1. Hover on h.HandleFunc

It will display a popover that includes the following link to docs:

(mux.MyHandler).HandleFuncon pkg.go.dev

As you can see, MyHandler is a struct in which *mux.Router is embedded. I don't get what (mux.MyHanlder) means and when you click on the link on the popover it goes to the top of the mux package documentation page, since there is no section called MyHandler.

If instead of h.HandleFunc I use h.Router.HandleFunc then everything is fine and the link displayed by VSCode will say (mux.Router).Handlefunc and when I click it I end up on the Router section of the mux package documentation.

The actual code I'm using is a little different (see below) but it annoys me that 1) the type reported by VSCode in the case of h.HandleFunc makes NO SENSE (what does "(mux.MyHandler)" even mean given that I'm just embedding mux.Router in MyHandler struct) and it's certainly showing buggy behavior by linking to a non-existing section of the package doc (mux.MyHandler).HandleFunc instead of (mux.Router).HandleFunc ...

func NewHandler() *MyHandler {
	h := &MyHandler{
               Router: mux.NewRouter(),
        }

	h.Router.HandleFunc("/api/v0/stream/{username}", h.handleStream).Methods("GET")

	return h
}

Screenshots or recordings

Screen Shot 2020-07-17 at 4 41 26 PM

@stamblerre stamblerre transferred this issue from golang/vscode-go Jul 19, 2020
@stamblerre stamblerre changed the title Link in popover goes to wrong section of package doc x/tools/gopls: hover link is incorrect for embedded struct Jul 19, 2020
@stamblerre stamblerre added this to the gopls/v0.5.0 milestone Jul 19, 2020
@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 Jul 19, 2020
@gopherbot
Copy link

Change https://golang.org/cl/244178 mentions this issue: internal/lsp: fix hover link for embedded fields and methods

@stamblerre stamblerre modified the milestones: gopls/v0.5.0, gopls/v1.0.0 Jul 22, 2020
@stamblerre stamblerre modified the milestones: gopls/v1.0.0, gopls/v0.4.4 Jul 27, 2020
@golang golang locked and limited conversation to collaborators Jul 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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