mirror of
https://github.com/golang/go
synced 2024-11-07 20:56:16 -07:00
cmd/go/internal/load: remove unused argument from Lookup
Change-Id: Ia2948a88c6d45a31be17b3d7415559cd53c289ce Reviewed-on: https://go-review.googlesource.com/128015 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
79faf9246e
commit
9ef5ee911c
@ -32,13 +32,13 @@ var (
|
|||||||
ModInit func()
|
ModInit func()
|
||||||
|
|
||||||
// module hooks; nil if module use is disabled
|
// module hooks; nil if module use is disabled
|
||||||
ModBinDir func() string // return effective bin directory
|
ModBinDir func() string // return effective bin directory
|
||||||
ModLookup func(parentPath, path string) (dir, realPath string, err error) // lookup effective meaning of import
|
ModLookup func(path string) (dir, realPath string, err error) // lookup effective meaning of import
|
||||||
ModPackageModuleInfo func(path string) *modinfo.ModulePublic // return module info for Package struct
|
ModPackageModuleInfo func(path string) *modinfo.ModulePublic // return module info for Package struct
|
||||||
ModImportPaths func(args []string) []string // expand import paths
|
ModImportPaths func(args []string) []string // expand import paths
|
||||||
ModPackageBuildInfo func(main string, deps []string) string // return module info to embed in binary
|
ModPackageBuildInfo func(main string, deps []string) string // return module info to embed in binary
|
||||||
ModInfoProg func(info string) []byte // wrap module info in .go code for binary
|
ModInfoProg func(info string) []byte // wrap module info in .go code for binary
|
||||||
ModImportFromFiles func([]string) // update go.mod to add modules for imports in these files
|
ModImportFromFiles func([]string) // update go.mod to add modules for imports in these files
|
||||||
)
|
)
|
||||||
|
|
||||||
var IgnoreImports bool // control whether we ignore imports in packages
|
var IgnoreImports bool // control whether we ignore imports in packages
|
||||||
@ -488,7 +488,7 @@ func LoadImport(path, srcDir string, parent *Package, stk *ImportStack, importPo
|
|||||||
importPath = dirToImportPath(filepath.Join(srcDir, path))
|
importPath = dirToImportPath(filepath.Join(srcDir, path))
|
||||||
} else if cfg.ModulesEnabled {
|
} else if cfg.ModulesEnabled {
|
||||||
var p string
|
var p string
|
||||||
modDir, p, modErr = ModLookup(parentPath, path)
|
modDir, p, modErr = ModLookup(path)
|
||||||
if modErr == nil {
|
if modErr == nil {
|
||||||
importPath = p
|
importPath = p
|
||||||
}
|
}
|
||||||
@ -628,11 +628,7 @@ func isDir(path string) bool {
|
|||||||
// Go 1.11 module legacy conversion (golang.org/issue/25069).
|
// Go 1.11 module legacy conversion (golang.org/issue/25069).
|
||||||
func ResolveImportPath(parent *Package, path string) (found string) {
|
func ResolveImportPath(parent *Package, path string) (found string) {
|
||||||
if cfg.ModulesEnabled {
|
if cfg.ModulesEnabled {
|
||||||
parentPath := ""
|
if _, p, e := ModLookup(path); e == nil {
|
||||||
if parent != nil {
|
|
||||||
parentPath = parent.ImportPath
|
|
||||||
}
|
|
||||||
if _, p, e := ModLookup(parentPath, path); e == nil {
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
@ -1771,7 +1767,7 @@ func LoadPackage(arg string, stk *ImportStack) *Package {
|
|||||||
return LoadImport(arg, base.Cwd, nil, stk, nil, 0)
|
return LoadImport(arg, base.Cwd, nil, stk, nil, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// packages returns the packages named by the
|
// Packages returns the packages named by the
|
||||||
// command line arguments 'args'. If a named package
|
// command line arguments 'args'. If a named package
|
||||||
// cannot be loaded at all (for example, if the directory does not exist),
|
// cannot be loaded at all (for example, if the directory does not exist),
|
||||||
// then packages prints an error and does not include that
|
// then packages prints an error and does not include that
|
||||||
@ -1791,7 +1787,7 @@ func Packages(args []string) []*Package {
|
|||||||
return pkgs
|
return pkgs
|
||||||
}
|
}
|
||||||
|
|
||||||
// packagesAndErrors is like 'packages' but returns a
|
// PackagesAndErrors is like 'packages' but returns a
|
||||||
// *Package for every argument, even the ones that
|
// *Package for every argument, even the ones that
|
||||||
// cannot be loaded at all.
|
// cannot be loaded at all.
|
||||||
// The packages that fail to load will have p.Error != nil.
|
// The packages that fail to load will have p.Error != nil.
|
||||||
|
@ -337,8 +337,10 @@ func ModuleUsedDirectly(path string) bool {
|
|||||||
return loaded.direct[path]
|
return loaded.direct[path]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup XXX TODO.
|
// Lookup returns the source directory and import path for the package at path.
|
||||||
func Lookup(parentPath, path string) (dir, realPath string, err error) {
|
// Lookup requires that one of the Load functions in this package has already
|
||||||
|
// been called.
|
||||||
|
func Lookup(path string) (dir, realPath string, err error) {
|
||||||
realPath = ImportMap(path)
|
realPath = ImportMap(path)
|
||||||
if realPath == "" {
|
if realPath == "" {
|
||||||
if isStandardImportPath(path) {
|
if isStandardImportPath(path) {
|
||||||
|
Loading…
Reference in New Issue
Block a user