Skip to content

hhhapz/doc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

doc

version reference tag

This module provides an API to programatically search the documentation of Go modules.

Usage

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

Options (opts...)

Currently there are two available options:

doc.MaintainCase()

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.

doc.UserAgent(string)

UserAgent will allow you to change the UA agent for all requests to the package sites. by default it will link to this repository.


Caching packages

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.

About

Query Go module documentation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages