Package-Level Type Names (total 4, all are exported)
/* sort exporteds by: | */
A Client is used by the fetch service to communicate with a module
proxy. It handles all methods defined by go help goproxy.
Whether fetch should be disabled.
Client used for HTTP requests. It is mutable for testing purposes.
lastZipModulePathstringlastZipReader*zip.ReaderlastZipVersionstring
One-element zip cache, to avoid a double download.
See TestFetchAndUpdateStateCacheZip in internal/worker/fetch_test.go.
Not thread-safe; should be used by only a single request goroutine.
URL of the module proxy web server
FetchDisabled reports whether proxy fetch is disabled.
Info makes a request to $GOPROXY/<module>/@v/<requestedVersion>.info and
transforms that data into a *VersionInfo.
If requestedVersion is internal.LatestVersion, it uses the proxy's @latest
endpoint instead.
Mod makes a request to $GOPROXY/<module>/@v/<resolvedVersion>.mod and returns the raw data.
Versions makes a request to $GOPROXY/<path>/@v/list and returns the
resulting version strings.
WithFetchDisabled returns a new client that sets the Disable-Module-Fetch
header so that the proxy does not fetch a module it doesn't already know
about.
WithZipCache returns a new client that caches the last zip
it downloads (not thread-safely).
Zip makes a request to $GOPROXY/<modulePath>/@v/<resolvedVersion>.zip and
transforms that data into a *zip.Reader. <resolvedVersion> must have already
been resolved by first making a request to
$GOPROXY/<modulePath>/@v/<requestedVersion>.info to obtained the valid
semantic version.
ZipSize gets the size in bytes of the zip from the proxy, without downloading it.
The version must be resolved, as by a call to Client.Info.
(*T) escapedURL(modulePath, requestedVersion, suffix string) (_ string, err error)
executeRequest executes an HTTP GET request for u, then calls the bodyFunc
on the response body, if no error occurred.
(*T) readBody(ctx context.Context, modulePath, requestedVersion, suffix string) (_ []byte, err error)
func New(u string) (_ *Client, err error)
func NewClientForServer(s *Server) (*Client, func(), error)
func SetupTestClient(t *testing.T, modules []*Module) (*Client, func())
func (*Client).WithFetchDisabled() *Client
func (*Client).WithZipCache() *Client
func golang.org/x/pkgsite/internal/fetch.FetchModule(ctx context.Context, modulePath, requestedVersion string, proxyClient *Client, sourceClient *source.Client) (fr *fetch.FetchResult)
func golang.org/x/pkgsite/internal/fetch.GetInfo(ctx context.Context, modulePath, requestedVersion string, proxyClient *Client) (_ *VersionInfo, err error)
func golang.org/x/pkgsite/internal/fetch.LatestModuleVersions(ctx context.Context, modulePath string, prox *Client, hasGoMod func(v string) (bool, error)) (info *internal.LatestModuleVersions, err error)
func golang.org/x/pkgsite/internal/frontend.FetchAndUpdateState(ctx context.Context, modulePath, requestedVersion string, proxyClient *Client, sourceClient *source.Client, db *postgres.DB) (_ int, err error)
func golang.org/x/pkgsite/internal/proxydatasource.New(proxyClient *Client) *proxydatasource.DataSource
func golang.org/x/pkgsite/internal/proxydatasource.NewBypassingLicenseCheck(c *Client) *proxydatasource.DataSource
func golang.org/x/pkgsite/internal/proxydatasource.NewForTesting(proxyClient *Client) *proxydatasource.DataSource
func golang.org/x/pkgsite/internal/fetch.fetchModule(ctx context.Context, fr *fetch.FetchResult, proxyClient *Client, sourceClient *source.Client) (*fetch.FetchInfo, error)
func golang.org/x/pkgsite/internal/fetch.getGoModPath(ctx context.Context, modulePath, resolvedVersion string, proxyClient *Client) (string, []byte, error)
func golang.org/x/pkgsite/internal/fetch.getZipSize(ctx context.Context, modulePath, resolvedVersion string, proxyClient *Client) (_ int64, err error)
func golang.org/x/pkgsite/internal/proxydatasource.newDataSource(proxyClient *Client, sourceClient *source.Client) *proxydatasource.DataSource
func golang.org/x/pkgsite/internal/worker.resolvedVersion(ctx context.Context, modulePath, requestedVersion string, proxyClient *Client) string
Server represents a proxy server containing the specified modules.
modulesmap[string][]*Modulemusync.Mutexmux*http.ServeMux
// number of .zip endpoint requests, for testing
AddModule adds an additional module to the server.
AddModuleNoLatest adds a module to the server, but the @v/list endpoint will
return nothing and @latest endpoint will serve a 410.
For testing the unusual case where a module exists but there is no version information.
AddRoute adds an additional handler to the server.
(*T) ZipRequests() int(*T) addModule(m *Module, hasVersions bool)
handleInfo creates an info endpoint for the specified module version.
handleLatest creates an info endpoint for the specified module at the latest
version.
handleList creates a list endpoint for the specified modulePath.
handleMod creates a mod endpoint for the specified module version.
handleZip creates a zip endpoint for the specified module version.
func NewServer(modules []*Module) *Server
func NewClientForServer(s *Server) (*Client, func(), error)
Package-Level Functions (total 10, in which 6 are exported)
FindModule returns the module in mods with the given path and version, or nil
if there isn't one. An empty version argument matches any version.
LoadTestModules reads the modules in the given directory. Each file in that
directory with a .txtar extension should be named "path@version" and should
be in txtar format (golang.org/x/tools/txtar). The path part of the filename
will be preceded by "example.com/" and colons will be replaced by slashes to
form a full module path. The file contents are used verbatim except that some
variables beginning with "$" are substituted with predefined strings.
LoadTestModules panics if there is an error reading any of the files.
New constructs a *Client using the provided url, which is expected to
be an absolute URI that can be directly passed to http.Get.
NewClientForServer starts serving proxyMux locally. It returns a client to the
server and a function to shut down the server.
NewServer returns a proxy Server that serves the provided modules.
SetupTestClient creates a fake module proxy for testing using the given test
version information.
It returns a function for tearing down the proxy after the test is completed
and a Client for interacting with the test proxy.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.