I'm looking for a convenient way to quickly look up the documentation for different functions and/or packages in Go. My current approach is to google for say ioutil.ReadFile
, but that is pretty slow/inconvenient.
The ideal solution would work directly in vim or maybe in a Go interpreter(suggestions?).
E.g. in Python the documentation of a function can be shown in PyDev by hovering over a function or using the ipython interpreter with e.g. os.open?
or help(os.open)
.
How do you view specific documentation for Go?
You have many possibilities:
$ godoc io/ioutil ReadFile
PACKAGE DOCUMENTATION
package ioutil
import "io/ioutil"
FUNCTIONS
func ReadFile(filename string) ([]byte, error)
ReadFile reads the file named by filename and returns the contents. A
successful call returns err == nil, not err == EOF. Because ReadFile
reads the whole file, it does not treat an EOF from Read as an error to
be reported.
$
doc
[0].$ doc ioutil.ReadFile
http://golang.org/pkg/io/ioutil/#ReadFile
/home/jnml/go/src/pkg/io/ioutil/ioutil.go:48:
// ReadFile reads the file named by filename and returns the contents.
// A successful call returns err == nil, not err == EOF. Because ReadFile
// reads the whole file, it does not treat an EOF from Read as an error
// to be reported.
func ReadFile(filename string) ([]byte, error)
$
[0]: $ go get code.google.com/p/rspace.cmd/doc