A command-line interface for querying pkg.go.dev.
Currently, the API is on v1beta, but we expect to move to v1 soon.
Related to issue 76718.
To install the pkgsite-cli tool, run:
go install golang.org/x/pkgsite/cmd/internal/pkgsite-cli@latest
The pkg.go.dev service provides an API interface at https://pkg.go.dev/api to allow querying information about published Go packages and modules. The API uses a stateless, GET-only architecture designed for stability and efficient caching. pkgsite-cli is a lightweight CLI that uses this API. There is no official SDK for the API, but this tool serves as a reference client implementation that developers can use in other projects. See the API spec and the OpenAPI specification.
go doc renders documentation for packages available locally. pkgsite-cli does not replace it for reading local documentation.cmd/pkgsite is a web server that serves documentation for packages available locally. It does not provide full version listings, vulnerability reports, reverse dependencies, licenses, or search capabilities (yet).pkgsite-cli provides access to information that go doc or a local instance of cmd/pkgsite cannot reach: version listings, vulnerability reports, reverse dependencies, licenses, documentation of modules/packages, and search results for packages not yet downloaded.Rule of thumb: Use go doc for local code; use pkgsite-cli for package discovery and metadata lookup.
Run pkgsite-cli <command> -h for details on available flags for each command.
Available commands:
packagemodulesearchAdditional commands will be added in the future.
pkgsite-cli search uuid
pkgsite-cli package github.com/google/go-cmp/cmp
pkgsite-cli package -imported-by github.com/google/go-cmp/cmp
pkgsite-cli package -symbols github.com/google/go-cmp/cmp
pkgsite-cli module -versions github.com/google/go-cmp
pkgsite-cli module -packages -versions github.com/google/go-cmp
go mod tidy or the pkg.go.dev web interface, which use the “longest module path” rule to resolve ambiguous package paths, the API requires the module to be specified unambiguously. If a package path is ambiguous because it exists in multiple modules, the API returns a list of candidates and reports an error. Use the -module flag to specify the correct module path.x/tools), the tool depends only on the Go standard library.pkgsite for now. We ruled out releasing a full SDK because the REST API is simple enough to consume directly. This keeps the tool self-contained. However, if this tool remains in this repository, we can eliminate this duplication by using the internal package.