Documentation
¶
Overview ¶
Package gomod is the library behind the gomod command line: the HTTP client, request shaping, and typed data models for the Go Module Proxy (proxy.golang.org).
The Client sets a real User-Agent, paces requests to 200 ms by default, and retries 429/5xx responses with exponential backoff.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) Info(ctx context.Context, module, version string) (*ModuleInfo, error)
- func (c *Client) Latest(ctx context.Context, module string) (*ModuleInfo, error)
- func (c *Client) Mod(ctx context.Context, module, version string) (*ModContent, error)
- func (c *Client) Versions(ctx context.Context, module string) ([]string, error)
- type Config
- type Domain
- type ModContent
- type ModuleInfo
Constants ¶
const DefaultBaseURL = "https://" + Host
DefaultBaseURL is the root every request is built from.
const DefaultUserAgent = "gomod/dev (+https://github.com/tamnd/gomod-cli)"
DefaultUserAgent identifies the client to proxy.golang.org.
const Host = "proxy.golang.org"
Host is the proxy hostname; the URI driver in domain.go claims it.
Variables ¶
var ErrNotFound = fmt.Errorf("not found")
ErrNotFound is returned when the proxy returns 404 for a module or version.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
// Rate is the minimum gap between requests. Zero means no pacing.
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to proxy.golang.org over HTTP.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Retries int
Timeout time.Duration
}
Config holds constructor parameters.
type Domain ¶
type Domain struct{}
Domain is the gomod driver.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type ModContent ¶
type ModContent struct {
Module string `json:"module"`
Version string `json:"version"`
Content string `json:"content"`
}
ModContent is returned by the mod command: the raw go.mod text.
type ModuleInfo ¶
type ModuleInfo struct {
Module string `json:"module"`
Version string `json:"version"`
Time string `json:"time,omitempty"`
}
ModuleInfo is returned by the latest and info commands.