Documentation
ΒΆ
Overview ΒΆ
Package pkggodev is a typed Go client for the pkg.go.dev API.
It wraps the ogen-generated client (under internal/api) with an ergonomic, context-first surface and clean response types.
Index ΒΆ
- Constants
- type Client
- func (c *Client) AllImportedBy(ctx context.Context, path string, opts ...Option) iter.Seq2[string, error]
- func (c *Client) AllPackages(ctx context.Context, path string, opts ...Option) iter.Seq2[PackageInfo, error]
- func (c *Client) AllSearch(ctx context.Context, opts ...Option) iter.Seq2[SearchResult, error]
- func (c *Client) AllSymbols(ctx context.Context, path string, opts ...Option) iter.Seq2[Symbol, error]
- func (c *Client) AllVersions(ctx context.Context, path string, opts ...Option) iter.Seq2[ModuleVersion, error]
- func (c *Client) AllVulns(ctx context.Context, path string, opts ...Option) iter.Seq2[Vulnerability, error]
- func (c *Client) ImportedBy(ctx context.Context, path string, opts ...Option) (*ImportedByResult, error)
- func (c *Client) Module(ctx context.Context, path string, opts ...Option) (*Module, error)
- func (c *Client) Package(ctx context.Context, path string, opts ...Option) (*Package, error)
- func (c *Client) Packages(ctx context.Context, path string, opts ...Option) (*PackagesResult, error)
- func (c *Client) Search(ctx context.Context, opts ...Option) (*Page[SearchResult], error)
- func (c *Client) Symbols(ctx context.Context, path string, opts ...Option) (*Page[Symbol], error)
- func (c *Client) Versions(ctx context.Context, path string, opts ...Option) (*Page[ModuleVersion], error)
- func (c *Client) Vulns(ctx context.Context, path string, opts ...Option) (*Page[Vulnerability], error)
- type ClientOption
- type ImportedByResult
- type License
- type Module
- type ModuleVersion
- type Option
- func WithDoc(s string) Option
- func WithExamples() Option
- func WithFilter(f string) Option
- func WithGOARCH(s string) Option
- func WithGOOS(s string) Option
- func WithImports() Option
- func WithLicenses() Option
- func WithLimit(n int) Option
- func WithModule(m string) Option
- func WithQuery(q string) Option
- func WithReadme() Option
- func WithSymbol(s string) Option
- func WithToken(t string) Option
- func WithVersion(v string) Option
- type Package
- type PackageInfo
- type PackagesResult
- type Page
- type Readme
- type SearchResult
- type Symbol
- type Vulnerability
Constants ΒΆ
const DefaultBaseURL = api.DefaultBaseURL
DefaultBaseURL is the production pkg.go.dev API base URL.
Variables ΒΆ
This section is empty.
Functions ΒΆ
This section is empty.
Types ΒΆ
type Client ΒΆ
type Client struct {
// contains filtered or unexported fields
}
Client is the pkg.go.dev API api.
func New ΒΆ
func New(opts ...ClientOption) (*Client, error)
New builds a pkg.go.dev client with sane defaults.
func (*Client) AllImportedBy ΒΆ
func (c *Client) AllImportedBy(ctx context.Context, path string, opts ...Option) iter.Seq2[string, error]
AllImportedBy iterates all packages that import the package at path.
func (*Client) AllPackages ΒΆ
func (c *Client) AllPackages(ctx context.Context, path string, opts ...Option) iter.Seq2[PackageInfo, error]
AllPackages iterates all packages contained in the module at path.
func (*Client) AllSymbols ΒΆ
func (c *Client) AllSymbols(ctx context.Context, path string, opts ...Option) iter.Seq2[Symbol, error]
AllSymbols iterates all exported symbols of the package at path.
func (*Client) AllVersions ΒΆ
func (c *Client) AllVersions(ctx context.Context, path string, opts ...Option) iter.Seq2[ModuleVersion, error]
AllVersions iterates all versions of the module at path, fetching pages lazily.
func (*Client) AllVulns ΒΆ
func (c *Client) AllVulns(ctx context.Context, path string, opts ...Option) iter.Seq2[Vulnerability, error]
AllVulns iterates all vulnerabilities for the module or package at path.
func (*Client) ImportedBy ΒΆ
func (c *Client) ImportedBy(ctx context.Context, path string, opts ...Option) (*ImportedByResult, error)
ImportedBy lists the packages that import the package at path.
func (*Client) Packages ΒΆ
func (c *Client) Packages(ctx context.Context, path string, opts ...Option) (*PackagesResult, error)
Packages lists the packages contained in the module at path.
type ClientOption ΒΆ
type ClientOption func(*clientConfig)
ClientOption configures the Client built by New.
func WithHTTPClient ΒΆ
func WithHTTPClient(h *http.Client) ClientOption
WithHTTPClient sets a custom *http.Client (timeouts, transport, etc.).
func WithUserAgent ΒΆ
func WithUserAgent(ua string) ClientOption
WithUserAgent sets the User-Agent header sent on every request.
type ImportedByResult ΒΆ
type ImportedByResult struct {
ModulePath string `json:"modulePath,omitempty"`
Version string `json:"version,omitempty"`
Packages Page[string] `json:"packages"`
}
ImportedByResult lists the packages that import a given package.
type License ΒΆ
type License struct {
Contents string `json:"contents,omitempty"`
FilePath string `json:"filePath,omitempty"`
Types []string `json:"types,omitempty"`
}
License describes a license file detected in a module or package.
type Module ΒΆ
type Module struct {
Path string `json:"path"`
Version string `json:"version,omitempty"`
RepoURL string `json:"repoUrl,omitempty"`
GoModContents string `json:"goModContents,omitempty"`
CommitTime time.Time `json:"commitTime,omitzero"`
HasGoMod bool `json:"hasGoMod"`
IsLatest bool `json:"isLatest"`
IsRedistributable bool `json:"isRedistributable"`
IsStandardLibrary bool `json:"isStandardLibrary"`
Licenses []License `json:"licenses,omitempty"`
Readme Readme `json:"readme,omitzero"`
}
Module is metadata about a single module.
type ModuleVersion ΒΆ
type ModuleVersion struct {
ModulePath string `json:"modulePath"`
Version string `json:"version"`
LatestVersion string `json:"latestVersion"`
CommitTime time.Time `json:"commitTime"`
HasGoMod bool `json:"hasGoMod"`
IsRedistributable bool `json:"isRedistributable"`
Deprecated bool `json:"deprecated"`
DeprecationReason string `json:"deprecationReason"`
Retracted bool `json:"retracted"`
RetractionReason string `json:"retractionReason"`
}
ModuleVersion is one entry from a /versions response.
type Option ΒΆ
type Option func(*params)
Option configures optional query parameters for a single API call. Each method ignores options that do not apply to it.
func WithExamples ΒΆ
func WithExamples() Option
WithExamples includes examples with returned documentation.
func WithFilter ΒΆ
WithFilter applies a regular-expression filter to listing results.
func WithGOARCH ΒΆ
WithGOARCH sets the GOARCH documentation build context.
func WithImports ΒΆ
func WithImports() Option
WithImports includes the list of packages the target imports.
func WithModule ΒΆ
WithModule sets the module path for package-scoped calls.
func WithReadme ΒΆ
func WithReadme() Option
WithReadme includes the README in the result (Module only).
func WithSymbol ΒΆ
WithSymbol sets the symbol search query (Search only).
func WithVersion ΒΆ
WithVersion selects a module version (semver, "latest", "master" or "main").
type Package ΒΆ
type Package struct {
Path string `json:"path"`
ModulePath string `json:"modulePath,omitempty"`
Name string `json:"name,omitempty"`
Synopsis string `json:"synopsis,omitempty"`
Version string `json:"version,omitempty"`
Goos string `json:"goos,omitempty"`
Goarch string `json:"goarch,omitempty"`
Docs string `json:"docs,omitempty"`
Imports []string `json:"imports,omitempty"`
IsLatest bool `json:"isLatest"`
IsRedistributable bool `json:"isRedistributable"`
IsStandardLibrary bool `json:"isStandardLibrary"`
Licenses []License `json:"licenses,omitempty"`
}
Package is documentation and metadata about a single package.
type PackageInfo ΒΆ
type PackageInfo struct {
Path string `json:"path"`
Name string `json:"name"`
Synopsis string `json:"synopsis"`
IsRedistributable bool `json:"isRedistributable"`
}
PackageInfo is one entry from a /packages response.
type PackagesResult ΒΆ
type PackagesResult struct {
ModulePath string `json:"modulePath,omitempty"`
Version string `json:"version,omitempty"`
IsStandardLibrary bool `json:"isStandardLibrary"`
Packages Page[PackageInfo] `json:"packages"`
}
PackagesResult lists the packages contained in a module.
type Page ΒΆ
type Page[T any] struct { Items []T `json:"items"` NextToken string `json:"nextToken,omitempty"` Total int `json:"total"` }
Page is a paginated slice of T returned by listing endpoints.
type Readme ΒΆ
type Readme struct {
Contents string `json:"contents,omitempty"`
Filepath string `json:"filepath,omitempty"`
}
Readme is a module README.
type SearchResult ΒΆ
type SearchResult struct {
ModulePath string `json:"modulePath"`
PackagePath string `json:"packagePath"`
Synopsis string `json:"synopsis"`
Version string `json:"version"`
}
SearchResult is one entry from a /search response.