gddo
gddo copied to clipboard
show imported packages in example snippets
Examples currently don't include the import paths of the referred packages, thus often requiring the user to refer to the actual example go file to copy paste the correct imports. Including the import path in the snippet can easily improve the case.
godoc.org so far has generally followed the behavior of cmd/godoc pretty closely. If I understand https://github.com/golang/go/issues/8223 correctly, the cmd/godoc command doesn't do this either, right? If so, are you suggesting that godoc.org deviate in behavior here?
To be clear, both should implement this feature.
Ah, that makes sense, thanks for clarifying. I'm in agreement with that.
The upstream godoc issue has been addressed by including imports and a surrounding func main() for each example. It would be nice if gddo could mirror this behavior.
The upstream godoc issue has been addressed by including imports and a surrounding
func main()for each example. It would be nice if gddo could mirror this behavior.
Can you provide a sample as the docs do not illustrate how to reproduce this?
https://golang.org/pkg/crypto/sha256/#example_New_file
The upstream godoc issue has been addressed by including imports and a surrounding func main() for each example.
When/where'd this happen? I can't find the relevant CL.
edit: Is it CL 83615?
I'm having trouble find the CL that introduced this. The reference to "Playable" in the godoc source goes back to 2014: https://golang.org/cl/64910043.
But I can't tell where the func main() business is happening in godoc.
example.html is the template, which extracts the .Output or .Play fields from go/doc.Example. iirc, gddo also uses go/doc, so this change could be ingested.