goproxy

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package goproxy provides Go modules proxy API client.

Index

Constants

View Source
const (
	DefaultProxyURL = "https://proxy.golang.org"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchiveReadCloser

type ArchiveReadCloser struct {
	io.ReadCloser

	// Size is content length in bytes.
	Size int64

	// ContentType is archive content type.
	ContentType string
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(client *http.Client, baseURL string) *Client

func NewClientFromEnv

func NewClientFromEnv() *Client

NewClientFromEnv returns a new client with address from GOPROXY environment variable.

Attention: only first address is respected. "direct" value is also ignored.

The default Go proxy URL is returned in case of error.

func NewClientWithDefaults

func NewClientWithDefaults() *Client

NewClientWithDefaults returns a new go modules proxy client with default http client and official Go Modules proxy server.

func (*Client) GetLatestVersion

func (c *Client) GetLatestVersion(ctx context.Context, pkgUrl string) (*VersionInfo, error)

GetLatestVersion returns information about a latest module version.

func (*Client) GetModuleFile

func (c *Client) GetModuleFile(ctx context.Context, pkgUrl, version string) ([]byte, error)

GetModuleFile returns go.mod file of specific version of a module.

func (*Client) GetModuleSource

func (c *Client) GetModuleSource(ctx context.Context, pkgUrl, version string) (*ArchiveReadCloser, error)

GetModuleSource returns zip archive stream for that version of the given module.

Returns a io.ReadCloser-compatible struct with size and content type information.

func (*Client) GetVersionInfo

func (c *Client) GetVersionInfo(ctx context.Context, pkgUrl, version string) (*VersionInfo, error)

GetVersionInfo returns information about module version.

func (*Client) GetVersions

func (c *Client) GetVersions(ctx context.Context, pkgUrl string) ([]string, error)

GetVersions returns a list of module versions.

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(baseURL string)

SetBaseURL updates proxy base URL

type HTTPError

type HTTPError struct {
	Code    int
	URL     string
	Message string
}

func IsHTTPError

func IsHTTPError(err error) (*HTTPError, bool)

func IsNotFoundError

func IsNotFoundError(err error) (*HTTPError, bool)

func (*HTTPError) Error

func (err *HTTPError) Error() string

type VersionInfo

type VersionInfo struct {
	Version string    `json:"Version"`
	Time    time.Time `json:"Time"`
}

Jump to

Keyboard shortcuts

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