Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search Go documentation?

Tags:

go

The documentation is great, but sometimes it is hard to find a specific keyword. For instance, searching for Next()results in this page http://golang.org/search?q=next%28%29 which is not very helpful. Is there a better way to search the documentation?

like image 266
Zeynel Avatar asked Jan 12 '23 22:01

Zeynel


1 Answers

Rob Pike wrote the perfect tool for this. Install it with go:

go get code.google.com/p/rspace.cmd/doc

You can then say doc next (or doc Next) and get an awesome list of Next functions in all packages, along with their documentations and signature. If you know the name of the package, you can say doc sql next or doc sql.next. You can even pass -url to get URL of that documentation online, or -src to get file name and line number for the implementation of that symbol.

You can access package documentation (documentation that appears at the top of a package’s page and doesn’t belong to any of its items) with -pkg: doc -pkg json.

doc searches for everything and you can limit it to only search for functions, interfaces, variables, etc. Run it without arguments to get the docs.

It’s such a great tool. Keep it close when you’re writing in Go.

like image 79
Mostafa Avatar answered Jan 30 '23 19:01

Mostafa