This module provides an API to programatically search the documentation of Go modules.
To import and use, go get github.com/hhhapz/doc
s := doc.New(http.DefaultClient, godocs.Parser, opts...) // or pkgsite.Parser
pkg, err := s.Search(context.TODO(), "bytes")
// use pkg
Currently there are two available options:
By default, the maps in the Package struct will have lower case keys:
Package.Functions
Package.Types
Package.Types.TypeFunctions
Package.Types.Methods
When enabling MaintainCase, the keys to all of these functions will be retained to their true case.
UserAgent will allow you to change the UA agent for all requests to the package sites. by default it will link to this repository.
The doc package also has a basic caching implementation that stores results in an in-memory map.
s := doc.New(http.DefaultClient, godocs.Parser) // or pkgsite.Parser
cs := doc.WithCache(s)
pkg, err := cs.Search(context.TODO(), "bytes")
// Cached results
pkg, err := cs.Search(context.TODO(), "bytes")
This package relies on https://godocs.io. It is planned to add a parser for pkgsite as well.