Constants & Variables
CmdMod
var
#
var CmdMod = *ast.UnaryExpr
cmdDownload
var
#
var cmdDownload = *ast.UnaryExpr
cmdEdit
var
#
var cmdEdit = *ast.UnaryExpr
cmdGraph
var
#
var cmdGraph = *ast.UnaryExpr
cmdInit
var
#
var cmdInit = *ast.UnaryExpr
cmdTidy
var
#
var cmdTidy = *ast.UnaryExpr
cmdVendor
var
#
var cmdVendor = *ast.UnaryExpr
cmdVerify
var
#
var cmdVerify = *ast.UnaryExpr
cmdWhy
var
#
var cmdWhy = *ast.UnaryExpr
copiedMetadata
var
#
var copiedMetadata = *ast.CallExpr
downloadJSON
var
#
var downloadJSON = *ast.CallExpr
downloadReuse
var
#
var downloadReuse = *ast.CallExpr
editFmt
var
#
var editFmt = *ast.CallExpr
editGo
var
#
var editGo = *ast.CallExpr
editJSON
var
#
var editJSON = *ast.CallExpr
editModule
var
#
var editModule = *ast.CallExpr
editPrint
var
#
var editPrint = *ast.CallExpr
editToolchain
var
#
var editToolchain = *ast.CallExpr
edits
var
#
var edits []func(*modfile.File)
graphGo
var
#
var graphGo goVersionFlag
metaPrefixes
var
#
var metaPrefixes = []string{...}
tidyCompat
var
#
var tidyCompat goVersionFlag
tidyDiff
var
#
var tidyDiff bool
tidyE
var
#
var tidyE bool
tidyGo
var
#
var tidyGo goVersionFlag
vendorE
var
#
var vendorE bool
vendorO
var
#
var vendorO string
whyM
var
#
var whyM = *ast.CallExpr
whyVendor
var
#
var whyVendor = *ast.CallExpr
Structs
ModuleJSON
struct
#
A ModuleJSON describes the result of go mod download.
type ModuleJSON struct {
Path string `json:",omitempty"`
Version string `json:",omitempty"`
Query string `json:",omitempty"`
Error string `json:",omitempty"`
Info string `json:",omitempty"`
GoMod string `json:",omitempty"`
Zip string `json:",omitempty"`
Dir string `json:",omitempty"`
Sum string `json:",omitempty"`
GoModSum string `json:",omitempty"`
Origin *codehost.Origin `json:",omitempty"`
Reuse bool `json:",omitempty"`
}
editModuleJSON
struct
#
type editModuleJSON struct {
Path string
Deprecated string `json:",omitempty"`
}
fileJSON
struct
#
fileJSON is the -json output data structure.
type fileJSON struct {
Module editModuleJSON
Go string `json:",omitempty"`
Toolchain string `json:",omitempty"`
Require []requireJSON
Exclude []module.Version
Replace []replaceJSON
Retract []retractJSON
Tool []toolJSON
}
goVersionFlag
struct
#
A goVersionFlag is a flag.Value representing a supported Go version.
(Note that the -go argument to 'go mod edit' is *not* a goVersionFlag.
It intentionally allows newer-than-supported versions as arguments.)
type goVersionFlag struct {
v string
}
metakey
struct
#
type metakey struct {
modPath string
dst string
}
replaceJSON
struct
#
type replaceJSON struct {
Old module.Version
New module.Version
}
requireJSON
struct
#
type requireJSON struct {
Path string
Version string `json:",omitempty"`
Indirect bool `json:",omitempty"`
}
retractJSON
struct
#
type retractJSON struct {
Low string `json:",omitempty"`
High string `json:",omitempty"`
Rationale string `json:",omitempty"`
}
toolJSON
struct
#
type toolJSON struct {
Path string
}
Functions
DownloadModule
function
#
DownloadModule runs 'go mod download' for m.Path@m.Version,
leaving the results (including any error) in m itself.
func DownloadModule(ctx context.Context, m *ModuleJSON) error
Get
method
#
func (f *goVersionFlag) Get() any
RunVendor
function
#
func RunVendor(ctx context.Context, vendorE bool, vendorO string, args []string)
Set
method
#
func (f *goVersionFlag) Set(s string) error
Set
method
#
func (f flagFunc) Set(s string) error
String
method
#
func (f *goVersionFlag) String() string
String
method
#
func (f flagFunc) String() string
allowedVersionArg
function
#
allowedVersionArg returns whether a token may be used as a version in go.mod.
We don't call modfile.CheckPathVersion, because that insists on versions
being in semver form, but here we want to allow versions like "master" or
"1234abcdef", which the go command will resolve the next time it runs (or
during -fix). Even so, we need to make sure the version is a valid token.
func allowedVersionArg(arg string) bool
checkPathCollisions
function
#
checkPathCollisions will fail if case-insensitive collisions are present.
The reason why we do this check in go mod vendor is to keep consistency
with go build. If modifying, consider changing load() in
src/cmd/go/internal/load/pkg.go
func checkPathCollisions(modpkgs map[module.Version][]string)
copyDir
function
#
copyDir copies all regular files satisfying match(info) from src to dst.
func copyDir(dst string, src string, match func(dir string, info fs.DirEntry) bool, copiedFiles map[string]bool)
copyMetadata
function
#
copyMetadata copies metadata files from parents of src to parents of dst,
stopping after processing the src parent for modPath.
func copyMetadata(modPath string, pkg string, dst string, src string, copiedFiles map[string]bool)
editPrintJSON
function
#
editPrintJSON prints the -json output.
func editPrintJSON(modFile *modfile.File)
flagDropExclude
function
#
flagDropExclude implements the -dropexclude flag.
func flagDropExclude(arg string)
flagDropGodebug
function
#
flagDropGodebug implements the -dropgodebug flag.
func flagDropGodebug(arg string)
flagDropReplace
function
#
flagDropReplace implements the -dropreplace flag.
func flagDropReplace(arg string)
flagDropRequire
function
#
flagDropRequire implements the -droprequire flag.
func flagDropRequire(arg string)
flagDropRetract
function
#
flagDropRetract implements the -dropretract flag.
func flagDropRetract(arg string)
flagDropTool
function
#
flagDropTool implements the -droptool flag.
func flagDropTool(arg string)
flagExclude
function
#
flagExclude implements the -exclude flag.
func flagExclude(arg string)
flagGodebug
function
#
flagGodebug implements the -godebug flag.
func flagGodebug(arg string)
flagReplace
function
#
flagReplace implements the -replace flag.
func flagReplace(arg string)
flagRequire
function
#
flagRequire implements the -require flag.
func flagRequire(arg string)
flagRetract
function
#
flagRetract implements the -retract flag.
func flagRetract(arg string)
flagTool
function
#
flagTool implements the -tool flag.
func flagTool(arg string)
init
function
#
func init()
init
function
#
func init()
init
function
#
func init()
init
function
#
func init()
init
function
#
func init()
init
function
#
func init()
init
function
#
func init()
init
function
#
func init()
matchMetadata
function
#
matchMetadata reports whether info is a metadata file.
func matchMetadata(dir string, info fs.DirEntry) bool
matchPotentialSourceFile
function
#
matchPotentialSourceFile reports whether info may be relevant to a build operation.
func matchPotentialSourceFile(dir string, info fs.DirEntry) bool
moduleLine
function
#
func moduleLine(m module.Version, r module.Version) string
parsePath
function
#
parsePath parses -flag=arg expecting arg to be path (not path@version).
func parsePath(flag string, arg string) (path string)
parsePathVersion
function
#
parsePathVersion parses -flag=arg expecting arg to be path@version.
func parsePathVersion(flag string, arg string) (path string, version string)
parsePathVersionOptional
function
#
parsePathVersionOptional parses path[@version], using adj to
describe any errors.
func parsePathVersionOptional(adj string, arg string, allowDirPath bool) (path string, version string, err error)
parseVersionInterval
function
#
parseVersionInterval parses a single version like "v1.2.3" or a closed
interval like "[v1.2.3,v1.4.5]". Note that a single version has the same
representation as an interval with equal upper and lower bounds: both
Low and High are set.
func parseVersionInterval(arg string) (modfile.VersionInterval, error)
runDownload
function
#
func runDownload(ctx context.Context, cmd *base.Command, args []string)
runEdit
function
#
func runEdit(ctx context.Context, cmd *base.Command, args []string)
runGraph
function
#
func runGraph(ctx context.Context, cmd *base.Command, args []string)
runInit
function
#
func runInit(ctx context.Context, cmd *base.Command, args []string)
runTidy
function
#
func runTidy(ctx context.Context, cmd *base.Command, args []string)
runVendor
function
#
func runVendor(ctx context.Context, cmd *base.Command, args []string)
runVerify
function
#
func runVerify(ctx context.Context, cmd *base.Command, args []string)
runWhy
function
#
func runWhy(ctx context.Context, cmd *base.Command, args []string)
vendorPkg
function
#
func vendorPkg(vdir string, pkg string)
verifyMod
function
#
func verifyMod(ctx context.Context, mod module.Version) []error