Reputation: 582
If I view a package's documentation via the web at https://pkg.go.dev, the page includes Example
test functions. The output of go doc -u -all
for a package does not. Is it possible to have such information included?
Upvotes: 9
Views: 1680
Reputation: 7050
I installed godoc with:
go install -v golang.org/x/tools/cmd/godoc@latest
And examples (if correctly named) are shown for me. I think you should correctly name your example functions in tests.
Upvotes: 0
Reputation: 121049
It is not possible to display examples using the go doc
command.
The command implementation ignores examples.
Upvotes: 5
Reputation: 430
Godoc examples are snippets of Go code that are displayed as package documentation and that are verified by running them as tests. They can also be run by a user visiting the godoc web page for the package and clicking the associated “Run” button
Upvotes: 1