x/tools/gopls: feature request - render example tests as part of hover documentation #71837
Labels
FeatureRequest
Issues asking for a new feature that does not need a proposal.
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
gopls version
v0.17.1
go env
What did you do?
I wanted to provide document usage for a public function, and I wanted its documentation to stay up-to-date. Luckily for me, Go's
testing
package supports testing examples associated with public functions: see https://pkg.go.dev/testing#hdr-Examples.I tried it out:
(the full code can be found at https://github.com/SKalt/temp.go/tree/25e36e5)
Finally, I hovered over my function expecting to see some reference to my example.
What did you see happen?
In VSCode, I couldn't see any reference to the example I associated with my function:

However, GoLand displayed footers in its on-hover doucumentation tooltip. The footer included a link to my example, the body of my example function, and the expected output.
What did you expect to see?
I'd like
gopls
to provide tested examples in on-hover docs like GoLand does. I think easier access to tested examples would be well worth the extra screen space!I'd be happy to implement this and submit a CL if I get buy-in. My plan is to write some sort of
findExamples()
call insidehover()
ingopls/internal/golang/hover.go
.Editor and settings
VScode:
Logs
No response
The text was updated successfully, but these errors were encountered: