proxy

package
v0.0.0-...-210767f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 18 Imported by: 0

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

View Source
const ProxyURL = "https://proxy.golang.org"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

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 NewClient

func NewClient(c *http.Client, url string) *Client

func NewDefaultClient

func NewDefaultClient() *Client

func NewTestClient

func NewTestClient(t *testing.T, update bool) (*Client, error)

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 (c *Client) CanonicalModulePath(path, version string) (_ string, err error)

func (*Client) CanonicalModuleVersion

func (c *Client) CanonicalModuleVersion(path, ver string) (_ string, err error)

CanonicalModuleVersion returns the canonical version string (with no leading "v" prefix) for the given module path and version string.

func (*Client) FindModule

func (c *Client) FindModule(path string) (modPath string, err error)

FindModule returns the longest directory prefix of path that is a module, or "" if no such prefix is found.

func (*Client) Latest

func (c *Client) Latest(path string) (string, error)

Latest returns the latest version of the module, with no leading "v" prefix.

func (*Client) ModuleExists

func (c *Client) ModuleExists(path string) bool

ModuleExists returns true if path is a recognized module.

func (*Client) ModuleExistsAtTaggedVersion

func (c *Client) ModuleExistsAtTaggedVersion(path, version string) bool

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).

func (*Client) Versions

func (c *Client) Versions(path string) ([]string, error)

Versions returns a list of module versions (with no leading "v" prefix), sorted in ascending order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL