Documentation ¶
Index ¶
- Variables
- func CachePath(m module.Version, suffix string) (string, error)
- func Download(mod module.Version) (dir string, err error)
- func DownloadDir(m module.Version) (string, error)
- func DownloadZip(mod module.Version) (zipfile string, err error)
- func GoMod(path, rev string) ([]byte, error)
- func GoModFile(path, version string) (string, error)
- func GoModSum(path, version string) (string, error)
- func ImportRepoRev(path, rev string) (Repo, *RevInfo, error)
- func InfoFile(path, version string) (string, error)
- func IsPseudoVersion(v string) bool
- func PseudoVersion(major, older string, t time.Time, rev string) string
- func PseudoVersionRev(v string) (rev string, err error)
- func PseudoVersionTime(v string) (time.Time, error)
- func RemoveAll(dir string) error
- func SideLock() (unlock func())
- func SortVersions(list []string)
- func Sum(mod module.Version) string
- func TrimGoSum(keep map[module.Version]bool)
- func Unzip(dir, zipfile, prefix string, maxSize int64) error
- func WriteGoSum()
- type Repo
- type RevInfo
Constants ¶
This section is empty.
Variables ¶
var GoSumFile string // path to go.sum; set by package modload
var HelpGoproxy = &base.Command{
UsageLine: "goproxy",
Short: "module proxy protocol",
Long: `
The go command by default downloads modules from version control systems
directly, just as 'go get' always has. The GOPROXY environment variable allows
further control over the download source. If GOPROXY is unset, is the empty string,
or is the string "direct", downloads use the default direct connection to version
control systems. Setting GOPROXY to "off" disallows downloading modules from
any source. Otherwise, GOPROXY is expected to be the URL of a module proxy,
in which case the go command will fetch all modules from that proxy.
No matter the source of the modules, downloaded modules must match existing
entries in go.sum (see 'go help modules' for discussion of verification).
A Go module proxy is any web server that can respond to GET requests for
URLs of a specified form. The requests have no query parameters, so even
a site serving from a fixed file system (including a file:/// URL)
can be a module proxy.
The GET requests sent to a Go module proxy are:
GET $GOPROXY/<module>/@v/list returns a list of all known versions of the
given module, one per line.
GET $GOPROXY/<module>/@v/<version>.info returns JSON-formatted metadata
about that version of the given module.
GET $GOPROXY/<module>/@v/<version>.mod returns the go.mod file
for that version of the given module.
GET $GOPROXY/<module>/@v/<version>.zip returns the zip archive
for that version of the given module.
To avoid problems when serving from case-sensitive file systems,
the <module> and <version> elements are case-encoded, replacing every
uppercase letter with an exclamation mark followed by the corresponding
lower-case letter: github.com/Azure encodes as github.com/!azure.
The JSON-formatted metadata about a given module corresponds to
this Go data structure, which may be expanded in the future:
type Info struct {
Version string // version string
Time time.Time // commit time
}
The zip archive for a specific version of a given module is a
standard zip file that contains the file tree corresponding
to the module's source code and related files. The archive uses
slash-separated paths, and every file path in the archive must
begin with <module>@<version>/, where the module and version are
substituted directly, not case-encoded. The root of the module
file tree corresponds to the <module>@<version>/ prefix in the
archive.
Even when downloading directly from version control systems,
the go command synthesizes explicit info, mod, and zip files
and stores them in its local cache, $GOPATH/pkg/mod/cache/download,
the same as if it had downloaded them directly from a proxy.
The cache layout is the same as the proxy URL space, so
serving $GOPATH/pkg/mod/cache/download at (or copying it to)
https://example.com/proxy would let other users access those
cached module versions with GOPROXY=https://example.com/proxy.
`,
}
var PkgMod string // $GOPATH/pkg/mod; set by package modload
var QuietLookup bool // do not print about lookups
Functions ¶
func Download ¶
Download downloads the specific module version to the local download cache and returns the name of the directory corresponding to the root of the module's file tree.
func DownloadDir ¶
DownloadDir returns the directory to which m should be downloaded. Note that the directory may not yet exist.
func DownloadZip ¶
DownloadZip downloads the specific module version to the local zip cache and returns the name of the zip file.
func GoMod ¶
GoMod is like Lookup(path).GoMod(rev) but avoids the repository path resolution in Lookup if the result is already cached on local disk.
func GoModFile ¶
GoModFile is like GoMod but returns the name of the file containing the cached information.
func GoModSum ¶
GoModSum returns the go.sum entry for the module version's go.mod file. (That is, it returns the entry listed in go.sum as "path version/go.mod".)
func ImportRepoRev ¶
ImportRepoRev returns the module and version to use to access the given import path loaded from the source code repository that the original "go get" would have used, at the specific repository revision (typically a commit hash, but possibly also a source control tag).
func InfoFile ¶
InfoFile is like Stat but returns the name of the file containing the cached information.
func IsPseudoVersion ¶
IsPseudoVersion reports whether v is a pseudo-version.
func PseudoVersion ¶
PseudoVersion returns a pseudo-version for the given major version ("v1") preexisting older tagged version ("" or "v1.2.3" or "v1.2.3-pre"), revision time, and revision identifier (usually a 12-byte commit hash prefix).
func PseudoVersionRev ¶
PseudoVersionRev returns the revision identifier of the pseudo-version v. It returns an error if v is not a pseudo-version.
func PseudoVersionTime ¶
PseudoVersionTime returns the time stamp of the pseudo-version v. It returns an error if v is not a pseudo-version or if the time stamp embedded in the pseudo-version is not a valid time.
func RemoveAll ¶
RemoveAll removes a directory written by Download or Unzip, first applying any permission changes needed to do so.
func SideLock ¶
func SideLock() (unlock func())
SideLock locks a file within the module cache that that guards edits to files outside the cache, such as go.sum and go.mod files in the user's working directory. It returns a function that must be called to unlock the file.
func SortVersions ¶
func SortVersions(list []string)
func Sum ¶
Sum returns the checksum for the downloaded copy of the given module, if present in the download cache.
Types ¶
type Repo ¶
type Repo interface { // ModulePath returns the module path. ModulePath() string // Versions lists all known versions with the given prefix. // Pseudo-versions are not included. // Versions should be returned sorted in semver order // (implementations can use SortVersions). Versions(prefix string) (tags []string, err error) // Stat returns information about the revision rev. // A revision can be any identifier known to the underlying service: // commit hash, branch, tag, and so on. Stat(rev string) (*RevInfo, error) // Latest returns the latest revision on the default branch, // whatever that means in the underlying source code repository. // It is only used when there are no tagged versions. Latest() (*RevInfo, error) // GoMod returns the go.mod file for the given version. GoMod(version string) (data []byte, err error) // Zip writes a zip file for the given version to dst. Zip(dst io.Writer, version string) error }
A Repo represents a repository storing all versions of a single module. It must be safe for simultaneous use by multiple goroutines.
type RevInfo ¶
type RevInfo struct { Version string // version string Time time.Time // commit time // These fields are used for Stat of arbitrary rev, // but they are not recorded when talking about module versions. Name string `json:"-"` // complete ID in underlying repository Short string `json:"-"` // shortened ID, for use in pseudo-version }
A Rev describes a single revision in a module repository.