Documentation
¶
Index ¶
- type APIError
- type Client
- func (c *Client) ImportedBy(ctx context.Context, path string, opts ...ImportedByOptions) (*Page[string], error)
- func (c *Client) ImportedByIter(ctx context.Context, path string, opts ...ImportedByOptions) iter.Seq2[string, error]
- func (c *Client) Module(ctx context.Context, path string, opts ...ModuleOptions) (*ModuleInfo, error)
- func (c *Client) ModulePackages(ctx context.Context, path string, opts ...ListOptions) (*Page[ModulePackage], error)
- func (c *Client) ModulePackagesIter(ctx context.Context, path string, opts ...ListOptions) iter.Seq2[ModulePackage, error]
- func (c *Client) Package(ctx context.Context, path string, opts ...PackageOptions) (*PackageInfo, error)
- func (c *Client) Search(ctx context.Context, query string, opts ...SearchOptions) (*Page[SearchResult], error)
- func (c *Client) SearchIter(ctx context.Context, query string, opts ...SearchOptions) iter.Seq2[SearchResult, error]
- func (c *Client) Symbols(ctx context.Context, path string, opts ...SymbolsOptions) (*Page[Symbol], error)
- func (c *Client) SymbolsIter(ctx context.Context, path string, opts ...SymbolsOptions) iter.Seq2[Symbol, error]
- func (c *Client) Versions(ctx context.Context, path string, opts ...VersionsOptions) (*Page[ModuleVersion], error)
- func (c *Client) VersionsIter(ctx context.Context, path string, opts ...VersionsOptions) iter.Seq2[ModuleVersion, error]
- func (c *Client) Vulnerabilities(ctx context.Context, path string, opts ...VulnsOptions) (*Page[Vulnerability], error)
- type ClientOption
- type ErrAmbiguousPath
- type ErrRateLimit
- type ImportedByOptions
- type ListOptions
- type ModuleInfo
- type ModuleOptions
- type ModulePackage
- type ModuleVersion
- type PackageInfo
- type PackageOptions
- type Page
- type RateLimit
- type SearchOptions
- type SearchResult
- type Symbol
- type SymbolsOptions
- type VersionsOptions
- type Vulnerability
- type VulnsOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError is returned when the API responds with a non-2xx status code that is not a known structured error (rate limit, ambiguous path, etc.).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a pkg.go.dev API client. The zero value is not usable; use NewClient.
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
NewClient returns a Client ready to make requests.
func (*Client) ImportedBy ¶
func (c *Client) ImportedBy(ctx context.Context, path string, opts ...ImportedByOptions) (*Page[string], error)
ImportedBy returns one page of the import paths of packages that import the given package. Use ImportedByIter to range over all of them without handling page tokens.
func (*Client) ImportedByIter ¶
func (c *Client) ImportedByIter(ctx context.Context, path string, opts ...ImportedByOptions) iter.Seq2[string, error]
ImportedByIter ranges over every import path that imports the given package, fetching successive pages as needed. On the first error it yields the zero value with that error and stops. Breaking out of the range loop stops cleanly.
func (*Client) Module ¶
func (c *Client) Module(ctx context.Context, path string, opts ...ModuleOptions) (*ModuleInfo, error)
Module returns metadata for the module at the given module path.
func (*Client) ModulePackages ¶
func (c *Client) ModulePackages(ctx context.Context, path string, opts ...ListOptions) (*Page[ModulePackage], error)
ModulePackages returns one page of the packages within a module. Use ModulePackagesIter to range over all of them without handling page tokens.
func (*Client) ModulePackagesIter ¶
func (c *Client) ModulePackagesIter(ctx context.Context, path string, opts ...ListOptions) iter.Seq2[ModulePackage, error]
ModulePackagesIter ranges over every package in the module, fetching successive pages as needed. On the first error it yields the zero value with that error and stops. Breaking out of the range loop stops cleanly.
func (*Client) Package ¶
func (c *Client) Package(ctx context.Context, path string, opts ...PackageOptions) (*PackageInfo, error)
Package returns metadata for the package at the given import path.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, query string, opts ...SearchOptions) (*Page[SearchResult], error)
Search returns one page of ranked results for the query. When SearchOptions.Symbol is set, the search is narrowed to packages exporting that symbol. Use SearchIter to range over all results without handling page tokens.
func (*Client) SearchIter ¶
func (c *Client) SearchIter(ctx context.Context, query string, opts ...SearchOptions) iter.Seq2[SearchResult, error]
SearchIter ranges over every result for the query, fetching successive pages as needed. On the first error it yields the zero value with that error and stops. Breaking out of the range loop stops cleanly.
func (*Client) Symbols ¶
func (c *Client) Symbols(ctx context.Context, path string, opts ...SymbolsOptions) (*Page[Symbol], error)
Symbols returns one page of the exported symbols in a package. Use SymbolsIter to range over all of them without handling page tokens.
func (*Client) SymbolsIter ¶
func (c *Client) SymbolsIter(ctx context.Context, path string, opts ...SymbolsOptions) iter.Seq2[Symbol, error]
SymbolsIter ranges over every exported symbol in the package, fetching successive pages as needed. On the first error it yields the zero value with that error and stops. Breaking out of the range loop stops cleanly.
func (*Client) Versions ¶
func (c *Client) Versions(ctx context.Context, path string, opts ...VersionsOptions) (*Page[ModuleVersion], error)
Versions returns one page of a module's version history. Use VersionsIter to range over every version without handling page tokens.
func (*Client) VersionsIter ¶
func (c *Client) VersionsIter(ctx context.Context, path string, opts ...VersionsOptions) iter.Seq2[ModuleVersion, error]
VersionsIter ranges over every version of the module, fetching successive pages as needed. On the first error it yields the zero value with that error and stops. Breaking out of the range loop stops cleanly.
func (*Client) Vulnerabilities ¶
func (c *Client) Vulnerabilities(ctx context.Context, path string, opts ...VulnsOptions) (*Page[Vulnerability], error)
Vulnerabilities returns the known vulnerabilities for the given module or package. The result is a single Page: the API does not paginate this endpoint because vulnerability lists are short, so there is no iterator variant. The common case is an empty list (no known vulnerabilities).
type ClientOption ¶
type ClientOption func(*Client)
ClientOption configures a Client.
func WithBaseURL ¶
func WithBaseURL(url string) ClientOption
WithBaseURL overrides the API base URL. Intended for testing against a local pkgsite instance.
func WithHTTPClient ¶
func WithHTTPClient(c *http.Client) ClientOption
WithHTTPClient replaces the default HTTP client. Useful for setting custom timeouts or transport-level behavior.
type ErrAmbiguousPath ¶
ErrAmbiguousPath is returned when a path could refer to more than one module. Retry the call with the Module option set to one of the Candidates.
func (*ErrAmbiguousPath) Error ¶
func (e *ErrAmbiguousPath) Error() string
type ErrRateLimit ¶
type ErrRateLimit struct {
RetryAfter int64 // Unix timestamp when the limit resets
}
ErrRateLimit is returned when the API responds with HTTP 429.
func (*ErrRateLimit) Error ¶
func (e *ErrRateLimit) Error() string
type ImportedByOptions ¶
type ImportedByOptions struct {
Module string
Version string
ListOptions
}
ImportedByOptions controls an ImportedBy request.
type ListOptions ¶
type ListOptions struct {
Limit int
Token string // page token from a previous response
Filter string // Go expression; will be URL-encoded automatically
}
ListOptions are shared by paginated endpoints.
type ModuleInfo ¶
type ModuleInfo struct {
Path string `json:"path"`
Version string `json:"version"`
CommitTime time.Time `json:"commitTime"`
IsLatest bool `json:"isLatest"`
IsRedistributable bool `json:"isRedistributable"`
IsStandardLibrary bool `json:"isStandardLibrary"`
HasGoMod bool `json:"hasGoMod"`
RepoURL string `json:"repoUrl"`
}
ModuleInfo holds metadata about a single Go module.
type ModuleOptions ¶
ModuleOptions controls optional fields in a Module request.
type ModulePackage ¶
type ModulePackage struct {
Path string `json:"path"`
Name string `json:"name"`
Synopsis string `json:"synopsis"`
IsRedistributable bool `json:"isRedistributable"`
}
ModulePackage is one package contained in a module.
type ModuleVersion ¶
type ModuleVersion struct {
ModulePath string `json:"modulePath"`
Version string `json:"version"`
CommitTime time.Time `json:"commitTime"`
IsRedistributable bool `json:"isRedistributable"`
HasGoMod bool `json:"hasGoMod"`
LatestVersion string `json:"latestVersion"`
Deprecated bool `json:"deprecated"`
DeprecationReason string `json:"deprecationReason"`
Retracted bool `json:"retracted"`
RetractionReason string `json:"retractionReason"`
}
ModuleVersion is one released version of a module. LatestVersion reports the latest version of the module, so a version is current when Version equals LatestVersion; the API does not send a per-item "is latest" flag.
type PackageInfo ¶
type PackageInfo struct {
ModulePath string `json:"modulePath"`
Version string `json:"version"`
CommitTime time.Time `json:"commitTime"`
IsLatest bool `json:"isLatest"`
IsStandardLibrary bool `json:"isStandardLibrary"`
GOOS string `json:"goos"`
GOARCH string `json:"goarch"`
Path string `json:"path"`
Name string `json:"name"`
Synopsis string `json:"synopsis"`
IsRedistributable bool `json:"isRedistributable"`
}
PackageInfo holds metadata about a single Go package.
type PackageOptions ¶
type PackageOptions struct {
Module string // disambiguate when the path matches multiple modules
Version string // specific version; defaults to latest
GOOS string
GOARCH string
Doc string // documentation format: text, html, md, markdown
Examples bool // include examples in documentation
Imports bool // include the packages this one imports
Licenses bool // include license information
}
PackageOptions controls optional fields in a Package request.
type RateLimit ¶
RateLimit holds the rate limit state read from the API response headers. It is zero-valued when the response did not include rate limit headers.
type SearchOptions ¶
type SearchOptions struct {
Symbol string // if set, search for this symbol within matching packages
ListOptions
}
SearchOptions controls a Search request.
type SearchResult ¶
type SearchResult struct {
PackagePath string `json:"packagePath"`
ModulePath string `json:"modulePath"`
Version string `json:"version"`
Name string `json:"name"`
Synopsis string `json:"synopsis"`
}
SearchResult is one ranked hit from a search.
type Symbol ¶
type Symbol struct {
Name string `json:"name"`
Kind string `json:"kind"` // const, var, type, func, method
Synopsis string `json:"synopsis"`
Parent string `json:"parent"` // enclosing type for methods and fields
}
Symbol is one exported symbol in a package.
type SymbolsOptions ¶
type SymbolsOptions struct {
Module string
Version string
GOOS string
GOARCH string
ListOptions
}
SymbolsOptions controls a Symbols request.
type VersionsOptions ¶
type VersionsOptions struct {
ListOptions
}
VersionsOptions controls a Versions request.
type Vulnerability ¶
type Vulnerability struct {
ID string `json:"id"`
Summary string `json:"summary"`
Details string `json:"details"`
FixedVersion string `json:"fixedVersion"`
}
Vulnerability is one entry from the Go vulnerability database affecting the queried module or package.
type VulnsOptions ¶
type VulnsOptions struct {
Module string
Version string
ListOptions
}
VulnsOptions controls a Vulnerabilities request.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
Package mock provides a test double for pkgsite.Client so consumers of the library can test their own code without making real HTTP calls.
|
Package mock provides a test double for pkgsite.Client so consumers of the library can test their own code without making real HTTP calls. |