Documentation ¶
Overview ¶
Package proxy provides a client and utilities for accessing the Go module proxy. Queries about the Go standard library and toolchain are not supported.
Index ¶
- Constants
- type Client
- func (c *Client) CanonicalModulePath(path, version string) (_ string, err error)
- func (c *Client) CanonicalModuleVersion(path, ver string) (_ string, err error)
- func (c *Client) FindModule(path string) (modPath string, err error)
- func (c *Client) Latest(path string) (string, error)
- func (c *Client) ModuleExists(path string) bool
- func (c *Client) ModuleExistsAtTaggedVersion(path, version string) bool
- func (c *Client) Versions(path string) ([]string, error)
Constants ¶
const ProxyURL = "https://proxy.golang.org"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a client for reading from the proxy.
It uses a simple in-memory cache that does not expire, which is acceptable because we use this Client in a short-lived context (~1 day at most, in the case of the worker, and a few seconds in the case of the vulnreport command), and module/version data does not change often enough to be a problem for our use cases.
func NewDefaultClient ¶
func NewDefaultClient() *Client
func NewTestClient ¶
NewTestClient creates a new client for testing. If update is true, the returned client contacts the real proxy and updates the file "testdata/proxy/<TestName>.json" with the responses it saw. If update is false, the returned client is a fake that reads saved responses from "testdata/proxy/<TestName>.json".
func (*Client) CanonicalModulePath ¶
func (*Client) CanonicalModuleVersion ¶
CanonicalModuleVersion returns the canonical version string (with no leading "v" prefix) for the given module path and version string.
func (*Client) FindModule ¶
FindModule returns the longest directory prefix of path that is a module, or "" if no such prefix is found.
func (*Client) Latest ¶
Latest returns the latest version of the module, with no leading "v" prefix.
func (*Client) ModuleExists ¶
ModuleExists returns true if path is a recognized module.
func (*Client) ModuleExistsAtTaggedVersion ¶
ModuleExistsAtTaggedVersion returns whether the given module path exists at the given version. The module need not be canonical, but the version must be an unprefixed canonical tagged version (e.g. 1.2.3 or 1.2.3+incompatible).