goproxy

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 9 Imported by: 6

Documentation

Overview

Package goproxy simple client for go modules proxy https://golang.org/cmd/go/#hdr-Module_proxy_protocol https://docs.gomods.io/intro/protocol/ https://go.googlesource.com/proposal/+/master/design/25530-sumdb.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
}

APIError represents an error from the GoProxy.

func (*APIError) Error

func (a *APIError) Error() string

type BasicAuthTransport

type BasicAuthTransport struct {

	// Transport is the underlying HTTP transport to use when making requests.
	// It will default to http.DefaultTransport if nil.
	Transport http.RoundTripper
	// contains filtered or unexported fields
}

BasicAuthTransport HTTP transport for API authentication.

func NewBasicAuthTransport

func NewBasicAuthTransport(username, password string) (*BasicAuthTransport, error)

NewBasicAuthTransport Creates a new BasicAuthTransport.

func (*BasicAuthTransport) Client

func (t *BasicAuthTransport) Client() *http.Client

Client Creates a new HTTP client.

func (*BasicAuthTransport) RoundTrip

func (t *BasicAuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction.

func (*BasicAuthTransport) Wrap

func (t *BasicAuthTransport) Wrap(client *http.Client) *http.Client

Wrap Wraps an HTTP client Transport with the BasicAuthTransport.

type Client

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

Client is the go modules proxy client.

func NewClient

func NewClient(proxyURL string) *Client

NewClient creates a new Client.

func (*Client) DownloadSources

func (c *Client) DownloadSources(moduleName, version string) (io.ReadCloser, error)

DownloadSources returns an io.ReadCloser that reads the contents of the archive file. It is the caller's responsibility to close the ReadCloser.

func (*Client) GetInfo

func (c *Client) GetInfo(moduleName, version string) (*VersionInfo, error)

GetInfo gets information about a module version.

<proxy URL>/<module name>/@v/<version>.info

func (*Client) GetLatest

func (c *Client) GetLatest(moduleName string) (*VersionInfo, error)

GetLatest gets information about the latest module version.

<proxy URL>/<module name>/@latest

func (*Client) GetModFile

func (c *Client) GetModFile(moduleName, version string) (*modfile.File, error)

GetModFile gets go.mod file.

func (*Client) GetSources

func (c *Client) GetSources(moduleName, version string) ([]byte, error)

GetSources gets the contents of the archive file.

func (*Client) GetVersions

func (c *Client) GetVersions(moduleName string) ([]string, error)

GetVersions gets all available module versions.

<proxy URL>/<module name>/@v/list

type VersionInfo

type VersionInfo struct {
	Name    string
	Short   string
	Version string
	Time    time.Time
}

VersionInfo is the representation of a version.

Jump to

Keyboard shortcuts

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