modfetch

package
v0.0.0-...-a371bc2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: BSD-3-Clause Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotPseudoVersion = errors.New("not a pseudo-version")
View Source
var GoSumFile string // path to go.sum; set by package modload
View Source
var QuietLookup bool // do not print about lookups
View Source
var SrcMod string // $GOPATH/src/mod; set by package modload

Functions

func CachePath

func CachePath(m module.Version, suffix string) (string, error)

func Download

func Download(mod module.Version) (dir string, err error)

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

func DownloadDir(m module.Version) (string, error)

func GoMod

func GoMod(path, rev string) ([]byte, error)

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 ImportRepoRev

func ImportRepoRev(path, rev string) (Repo, *RevInfo, error)

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 IsPseudoVersion

func IsPseudoVersion(v string) bool

IsPseudoVersion reports whether v is a pseudo-version.

func PseudoVersion

func PseudoVersion(major string, t time.Time, rev string) string

func PseudoVersionTime

func PseudoVersionTime(v string) (time.Time, error)

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 SortVersions

func SortVersions(list []string)

func Sum

func Sum(mod module.Version) string

Sum returns the checksum for the downloaded copy of the given module, if present in the download cache.

func Unzip

func Unzip(dir, zipfile, prefix string, maxSize int64) error

func WriteGoSum

func WriteGoSum()

WriteGoSum writes the go.sum file if it needs to be updated.

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 downloads a zip file for the given version
	// to a new file in a given temporary directory.
	// It returns the name of the new file.
	// The caller should remove the file when finished with it.
	Zip(version, tmpdir string) (tmpfile string, err error)
}

A Repo represents a repository storing all versions of a single module. It must be safe for simultaneous use by multiple goroutines.

func Lookup

func Lookup(path string) (Repo, error)

Lookup returns the module with the given module path. A successful return does not guarantee that the module has any defined versions.

type RevInfo

type RevInfo struct {
	Version string    // version string
	Name    string    // complete ID in underlying repository
	Short   string    // shortened ID, for use in pseudo-version
	Time    time.Time // commit time
}

A Rev describes a single revision in a module repository.

func Stat

func Stat(path, rev string) (*RevInfo, error)

Stat is like Lookup(path).Stat(rev) but avoids the repository path resolution in Lookup if the result is already cached on local disk.

Directories

Path Synopsis
Package codehost defines the interface implemented by a code hosting source, along with support code for use by implementations.
Package codehost defines the interface implemented by a code hosting source, along with support code for use by implementations.

Jump to

Keyboard shortcuts

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