Documentation
¶
Index ¶
- Constants
- Variables
- func AllowMissingModuleImports()
- func BinDir() string
- func CheckAllowed(ctx context.Context, m module.Version) error
- func CheckDeprecation(ctx context.Context, m module.Version) (deprecation string, err error)
- func CheckExclusions(ctx context.Context, m module.Version) error
- func CheckRetractions(ctx context.Context, m module.Version) (err error)
- func CreateModFile(ctx context.Context, modPath string)
- func CreateWorkFile(ctx context.Context, workFile string, modDirs []string)
- func EditBuildList(ctx context.Context, add, mustSelect []module.Version) (changed bool, err error)
- func Enabled() bool
- func EnterModule(ctx context.Context, enterModroot string)
- func HasModRoot() bool
- func ImportFromFiles(ctx context.Context, gofiles []string)
- func ImportMap(path string) string
- func Init()
- func InitWorkfile()
- func IsRevisionQuery(vers string) bool
- func LatestGoVersion() string
- func ListModules(ctx context.Context, args []string, mode ListMode, reuseFile string) ([]*modinfo.ModulePublic, error)
- func LoadPackages(ctx context.Context, opts PackageOpts, patterns ...string) (matches []*search.Match, loadedPackages []string)
- func Lookup(parentPath string, parentIsStd bool, path string) (dir, realPath string, err error)
- func MatchInModule(ctx context.Context, pattern string, m module.Version, tags map[string]bool) *search.Match
- func ModFile() *modfile.File
- func ModFilePath() string
- func ModInfoData(info string) []byte
- func ModInfoProg(info string, isgccgo bool) []byte
- func ModuleInfo(ctx context.Context, path string) *modinfo.ModulePublic
- func MustHaveModRoot()
- func PackageDir(path string) string
- func PackageModRoot(ctx context.Context, pkgpath string) string
- func PackageModule(path string) module.Version
- func PackageModuleInfo(ctx context.Context, pkgpath string) *modinfo.ModulePublic
- func Query(ctx context.Context, path, query, current string, allowed AllowedFunc) (*modfetch.RevInfo, error)
- func QueryPattern(ctx context.Context, pattern, query string, current func(string) string, ...) (pkgMods []QueryResult, modOnly *QueryResult, err error)
- func ReadModFile(gomod string, fix modfile.VersionFixer) (data []byte, f *modfile.File, err error)
- func ReadWorkFile(path string) (*modfile.WorkFile, error)
- func Replacement(mod module.Version) module.Version
- func ShortMessage(message, emptyDefault string) string
- func ToDirectoryPath(path string) string
- func UpdateWorkFile(wf *modfile.WorkFile)
- func VendorDir() string
- func Why(path string) string
- func WhyDepth(path string) int
- func WillBeEnabled() bool
- func WorkFilePath() string
- func WriteGoMod(ctx context.Context) error
- func WriteWorkFile(path string, wf *modfile.WorkFile) error
- type AllowedFunc
- type AmbiguousImportError
- type Conflict
- type ConstraintError
- type DirectImportFromImplicitDependencyError
- type ImportMissingError
- type ImportMissingSumError
- type ListMode
- type MainModuleSet
- func (mms *MainModuleSet) Contains(path string) bool
- func (mms *MainModuleSet) DirImportPath(ctx context.Context, dir string) (path string, m module.Version)
- func (mms *MainModuleSet) GetSingleIndexOrNil() *modFileIndex
- func (mms *MainModuleSet) GoVersion() string
- func (mms *MainModuleSet) HighestReplaced() map[string]string
- func (mms *MainModuleSet) InGorootSrc(m module.Version) bool
- func (mms *MainModuleSet) Index(m module.Version) *modFileIndex
- func (mms *MainModuleSet) Len() int
- func (mms *MainModuleSet) ModContainingCWD() module.Version
- func (mms *MainModuleSet) ModFile(m module.Version) *modfile.File
- func (mms *MainModuleSet) ModRoot(m module.Version) string
- func (mms *MainModuleSet) PathPrefix(m module.Version) string
- func (mms *MainModuleSet) SetIndex(m module.Version, index *modFileIndex)
- func (mms *MainModuleSet) Versions() []module.Version
- func (mms *MainModuleSet) WorkFileReplaceMap() map[module.Version]module.Version
- type ModuleGraph
- type ModuleRetractedError
- type NoMatchingVersionError
- type NoPatchBaseError
- type PackageNotInModuleError
- type PackageOpts
- type QueryMatchesMainModulesError
- type QueryMatchesPackagesInMainModuleError
- type QueryResult
- type QueryUpgradesAllError
- type Requirements
- type Root
- type WildcardInFirstElementError
Constants ¶
View Source
const ( // ExplicitIndirectVersionV is the Go version (plus leading "v") at which a // module's go.mod file is expected to list explicit requirements on every // module that provides any package transitively imported by that module. // // Other indirect dependencies of such a module can be safely pruned out of // the module graph; see https://golang.org/ref/mod#graph-pruning. ExplicitIndirectVersionV = "v1.17" )
Variables ¶
View Source
var ( // RootMode determines whether a module root is needed. RootMode Root // ForceUseModules may be set to force modules to be enabled when // GO111MODULE=auto or to report an error when GO111MODULE=off. ForceUseModules bool // ExplicitWriteGoMod prevents LoadPackages, ListModules, and other functions // from updating go.mod and go.sum or reporting errors when updates are // needed. A package should set this if it would cause go.mod to be written // multiple times (for example, 'go get' calls LoadPackages multiple times) or // if it needs some other operation to be successful before go.mod and go.sum // can be written (for example, 'go mod download' must download modules before // adding sums to go.sum). Packages that set this are responsible for calling // WriteGoMod explicitly. ExplicitWriteGoMod bool )
Variables set by other packages.
TODO(#40775): See if these can be plumbed as explicit parameters.
View Source
var ErrDisallowed = errors.New("disallowed module version")
ErrDisallowed is returned by version predicates passed to Query and similar functions to indicate that a version should not be considered.
View Source
var ErrNoModRoot = errors.New("go.mod file not found in current directory or any parent directory; see 'go help modules'")
View Source
var HelpGoMod = &base.Command{
UsageLine: "go.mod",
Short: "the go.mod file",
Long: `
A module version is defined by a tree of source files, with a go.mod
file in its root. When the go command is run, it looks in the current
directory and then successive parent directories to find the go.mod
marking the root of the main (current) module.
The go.mod file format is described in detail at
https://golang.org/ref/mod#go-mod-file.
To create a new go.mod file, use 'go mod init'. For details see
'go help mod init' or https://golang.org/ref/mod#go-mod-init.
To add missing module requirements or remove unneeded requirements,
use 'go mod tidy'. For details, see 'go help mod tidy' or
https://golang.org/ref/mod#go-mod-tidy.
To add, upgrade, downgrade, or remove a specific module requirement, use
'go get'. For details, see 'go help module-get' or
https://golang.org/ref/mod#go-get.
To make other changes or to parse go.mod as JSON for use by other tools,
use 'go mod edit'. See 'go help mod edit' or
https://golang.org/ref/mod#go-mod-edit.
`,
}
View Source
var HelpModules = &base.Command{
UsageLine: "modules",
Short: "modules, module versions, and more",
Long: `
Modules are how Go manages dependencies.
A module is a collection of packages that are released, versioned, and
distributed together. Modules may be downloaded directly from version control
repositories or from module proxy servers.
For a series of tutorials on modules, see
https://golang.org/doc/tutorial/create-module.
For a detailed reference on modules, see https://golang.org/ref/mod.
By default, the go command may download modules from https://proxy.golang.org.
It may authenticate modules using the checksum database at
https://sum.golang.org. Both services are operated by the Go team at Google.
The privacy policies for these services are available at
https://proxy.golang.org/privacy and https://sum.golang.org/privacy,
respectively.
The go command's download behavior may be configured using GOPROXY, GOSUMDB,
GOPRIVATE, and other environment variables. See 'go help environment'
and https://golang.org/ref/mod#private-module-privacy for more information.
`,
}
Functions ¶
func AllowMissingModuleImports ¶ added in go1.14
func AllowMissingModuleImports()
AllowMissingModuleImports allows import paths to be resolved to modules when there is no module root. Normally, this is forbidden because it's slow and there's no way to make the result reproducible, but some commands like 'go get' are expected to do this.
This function affects the default cfg.BuildMod when outside of a module, so it can only be called prior to Init.