sourcegraph / go-langserver

Go language server to add Go support to editors and other tools that use the Language Server Protocol (LSP)
https://sourcegraph.com
MIT License
1.17k stars 89 forks source link

Include examples in hover tooltips #335

Open nicksnyder opened 6 years ago

nicksnyder commented 6 years ago

It would be neat if the go language server included at least one example (when available) in the hover tooltip for a symbol.

To a first approximation, the example part of the result of godoc -ex <package> <symbol> (e.g. godoc -ex io MultiReader)

Example:
    r1 := strings.NewReader("first reader ")
    r2 := strings.NewReader("second reader ")
    r3 := strings.NewReader("third reader\n")
    r := io.MultiReader(r1, r2, r3)

    if _, err := io.Copy(os.Stdout, r); err != nil {
        log.Fatal(err)
    }

    // Output:
    // first reader second reader third reader