Structs
Cmd
struct
#
A Cmd describes how to use a version control system
like Mercurial, Git, or Subversion.
type Cmd struct {
Name string
Cmd string
Env []string
RootNames []rootName
CreateCmd []string
DownloadCmd []string
TagCmd []tagCmd
TagLookupCmd []tagCmd
TagSyncCmd []string
TagSyncDefault []string
Scheme []string
PingCmd string
RemoteRepo func(v *Cmd, rootDir string) (remoteRepo string, err error)
ResolveRepo func(v *Cmd, rootDir string, remoteRepo string) (realRepo string, err error)
Status func(v *Cmd, rootDir string) (Status, error)
}
ImportMismatchError
struct
#
An ImportMismatchError is returned where metaImport/s are present
but none match our import path.
type ImportMismatchError struct {
importPath string
mismatches []string
}
RepoRoot
struct
#
RepoRoot describes the repository root for a tree of source code.
type RepoRoot struct {
Repo string
Root string
IsCustom bool
VCS *Cmd
}
Status
struct
#
Status is the current state of a local repository.
type Status struct {
Revision string
CommitTime time.Time
Uncommitted bool
}
fetchResult
struct
#
type fetchResult struct {
url *urlpkg.URL
imports []metaImport
err error
}
govcsRule
struct
#
A govcsRule is a single GOVCS rule like private:hg|svn.
type govcsRule struct {
pattern string
allowed []string
}
importError
struct
#
importError is a copy of load.importError, made to avoid a dependency cycle
on cmd/go/internal/load. It just needs to satisfy load.ImportPathError.
type importError struct {
importPath string
err error
}
metaImport
struct
#
metaImport represents the parsed tags from HTML files.
type metaImport struct {
Prefix string
VCS string
RepoRoot string
}
rootName
struct
#
type rootName struct {
filename string
isDir bool
}
tagCmd
struct
#
A tagCmd describes a command to list available tags
that can be passed to tagSyncCmd.
type tagCmd struct {
cmd string
pattern string
}
vcsNotFoundError
struct
#
type vcsNotFoundError struct {
dir string
}
vcsPath
struct
#
A vcsPath describes how to convert an import path into a
version control system and repository name.
type vcsPath struct {
pathPrefix string
regexp *lazyregexp.Regexp
repo string
vcs string
check func(match map[string]string) error
schemelessRepo bool
}
Functions
Create
method
#
Create creates a new copy of repo in dir.
The parent of dir must exist; dir must not.
func (v *Cmd) Create(dir string, repo string) error
Download
method
#
Download downloads any new changes for the repo in dir.
func (v *Cmd) Download(dir string) error
Error
method
#
func (e *vcsNotFoundError) Error() string
Error
method
#
func (e *importError) Error() string
Error
method
#
func (m ImportMismatchError) Error() string
FromDir
function
#
FromDir inspects dir and its parents to determine the
version control system and code repository to use.
If no repository is found, FromDir returns an error
equivalent to os.ErrNotExist.
func FromDir(dir string, srcRoot string) (repoDir string, vcsCmd *Cmd, err error)
ImportPath
method
#
func (e *importError) ImportPath() string
Is
method
#
func (e *vcsNotFoundError) Is(err error) bool
IsSecure
method
#
func (v *Cmd) IsSecure(repo string) bool
Ping
method
#
Ping pings to determine scheme to use.
func (v *Cmd) Ping(scheme string, repo string) error
RepoRootForImportPath
function
#
RepoRootForImportPath analyzes importPath to determine the
version control system, and code repository to use.
func RepoRootForImportPath(importPath string, mod ModuleMode, security web.SecurityMode) (*RepoRoot, error)
String
method
#
func (v *Cmd) String() string
TagSync
method
#
TagSync syncs the repo in dir to the named tag,
which either is a tag returned by tags or is v.tagDefault.
func (v *Cmd) TagSync(dir string, tag string) error
Tags
method
#
Tags returns the list of available tags for the repo in dir.
func (v *Cmd) Tags(dir string) ([]string, error)
Unwrap
method
#
func (e *importError) Unwrap() error
allow
method
#
func (c *govcsConfig) allow(path string, private bool, vcs string) bool
attrValue
function
#
attrValue returns the attribute value for the case-insensitive key
`name`, or the empty string if nothing is found.
func attrValue(attrs []xml.Attr, name string) string
bzrRemoteRepo
function
#
func bzrRemoteRepo(vcsBzr *Cmd, rootDir string) (remoteRepo string, err error)
bzrResolveRepo
function
#
func bzrResolveRepo(vcsBzr *Cmd, rootDir string, remoteRepo string) (realRepo string, err error)
bzrStatus
function
#
func bzrStatus(vcsBzr *Cmd, rootDir string) (Status, error)
charsetReader
function
#
charsetReader returns a reader that converts from the given charset to UTF-8.
Currently it only supports UTF-8 and ASCII. Otherwise, it returns a meaningful
error which is printed by go get, so the user can find why the package
wasn't downloaded if the encoding is not supported. Note that, in
order to reduce potential errors, ASCII is treated as UTF-8 (i.e. characters
greater than 0x7f are not rejected).
func charsetReader(charset string, input io.Reader) (io.Reader, error)
checkGOVCS
function
#
checkGOVCS checks whether the policy defined by the environment variable
GOVCS allows the given vcs command to be used with the given repository
root path. Note that root may not be a real package or module path; it's
the same as the root path in the go-import meta tag.
func checkGOVCS(vcs *Cmd, root string) error
expand
function
#
expand rewrites s to replace {k} with match[k] for each key k in match.
func expand(match map[string]string, s string) string
fossilRemoteRepo
function
#
func fossilRemoteRepo(vcsFossil *Cmd, rootDir string) (remoteRepo string, err error)
fossilStatus
function
#
func fossilStatus(vcsFossil *Cmd, rootDir string) (Status, error)
gitRemoteRepo
function
#
func gitRemoteRepo(vcsGit *Cmd, rootDir string) (remoteRepo string, err error)
gitStatus
function
#
func gitStatus(vcsGit *Cmd, rootDir string) (Status, error)
hgRemoteRepo
function
#
func hgRemoteRepo(vcsHg *Cmd, rootDir string) (remoteRepo string, err error)
hgStatus
function
#
func hgStatus(vcsHg *Cmd, rootDir string) (Status, error)
httpPrefix
function
#
func httpPrefix(s string) string
importErrorf
function
#
func importErrorf(path string, format string, args ...any) error
interceptVCSTest
function
#
func interceptVCSTest(repo string, vcs *Cmd, security web.SecurityMode) (repoURL string, ok bool)
isSecureScheme
method
#
func (v *Cmd) isSecureScheme(scheme string) bool
isVCSRoot
function
#
isVCSRoot identifies a VCS root by checking whether the directory contains
any of the listed root names.
func isVCSRoot(dir string, rootNames []rootName) bool
launchpadVCS
function
#
launchpadVCS solves the ambiguity for "lp.net/project/foo". In this case,
"foo" could be a series name registered in Launchpad with its own branch,
and it could also be the name of a directory within the main project
branch one level up.
func launchpadVCS(match map[string]string) error
matchGoImport
function
#
matchGoImport returns the metaImport from imports matching importPath.
An error is returned if there are multiple matches.
An ImportMismatchError is returned if none match.
func matchGoImport(imports []metaImport, importPath string) (metaImport, error)
metaImportsForPrefix
function
#
metaImportsForPrefix takes a package's root import path as declared in a tag
and returns its HTML discovery URL and the parsed metaImport lines
found on the page.
The importPath is of the form "golang.org/x/tools".
It is an error if no imports are found.
url will still be valid if err != nil.
The returned url will be of the form "https://golang.org/x/tools?go-get=1"
func metaImportsForPrefix(importPrefix string, mod ModuleMode, security web.SecurityMode) (*urlpkg.URL, []metaImport, error)
noVCSSuffix
function
#
noVCSSuffix checks that the repository name does not
end in .foo for any version control system foo.
The usual culprit is ".git".
func noVCSSuffix(match map[string]string) error
parseGOVCS
function
#
func parseGOVCS(s string) (govcsConfig, error)
parseMetaGoImports
function
#
parseMetaGoImports returns meta imports from the HTML in r.
Parsing ends at the end of the
section or the beginning of the .
func parseMetaGoImports(r io.Reader, mod ModuleMode) ([]metaImport, error)
parseRevTime
function
#
parseRevTime parses commit details in "revision:seconds" format.
func parseRevTime(out []byte) (string, time.Time, error)
repoRootForImportDynamic
function
#
repoRootForImportDynamic finds a *RepoRoot for a custom domain that's not
statically known by repoRootFromVCSPaths.
This handles custom import paths like "name.tld/pkg/foo" or just "name.tld".
func repoRootForImportDynamic(importPath string, mod ModuleMode, security web.SecurityMode) (*RepoRoot, error)
repoRootFromVCSPaths
function
#
repoRootFromVCSPaths attempts to map importPath to a repoRoot
using the mappings defined in vcsPaths.
func repoRootFromVCSPaths(importPath string, security web.SecurityMode, vcsPaths []*vcsPath) (*RepoRoot, error)
run
method
#
run runs the command line cmd in the given directory.
keyval is a list of key, value pairs. run expands
instances of {key} in cmd into value, but only after
splitting cmd into individual arguments.
If an error occurs, run prints the command line and the
command's combined stdout+stderr to standard error.
Otherwise run discards the command's output.
func (v *Cmd) run(dir string, cmd string, keyval ...string) error
run1
method
#
run1 is the generalized implementation of run and runOutput.
func (v *Cmd) run1(dir string, cmdline string, keyval []string, verbose bool) ([]byte, error)
runOutput
method
#
runOutput is like run but returns the output of the command.
func (v *Cmd) runOutput(dir string, cmd string, keyval ...string) ([]byte, error)
runOutputVerboseOnly
method
#
runOutputVerboseOnly is like runOutput but only generates error output to
standard error in verbose mode.
func (v *Cmd) runOutputVerboseOnly(dir string, cmd string, keyval ...string) ([]byte, error)
runVerboseOnly
method
#
runVerboseOnly is like run but only generates error output to standard error in verbose mode.
func (v *Cmd) runVerboseOnly(dir string, cmd string, keyval ...string) error
svnRemoteRepo
function
#
func svnRemoteRepo(vcsSvn *Cmd, rootDir string) (remoteRepo string, err error)
urlForImportPath
function
#
urlForImportPath returns a partially-populated URL for the given Go import path.
The URL leaves the Scheme field blank so that web.Get will try any scheme
allowed by the selected security mode.
func urlForImportPath(importPath string) (*urlpkg.URL, error)
validateRepoRoot
function
#
validateRepoRoot returns an error if repoRoot does not seem to be
a valid URL with scheme.
func validateRepoRoot(repoRoot string) error
vcsByCmd
function
#
vcsByCmd returns the version control system for the given
command name (hg, git, svn, bzr).
func vcsByCmd(cmd string) *Cmd