]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/go/internal/load/pkg.go
[dev.boringcrypto] all: merge master into dev.boringcrypto
[gostls13.git] / src / cmd / go / internal / load / pkg.go
index aba1dfd1c163bafe722229a84c8fb4a5ba2ff9b1..1a510b86c71eb893f7f1c3452e69e6182e792b09 100644 (file)
@@ -825,11 +825,11 @@ func loadPackageData(ctx context.Context, path, parentPath, parentDir, parentRoo
        }
        r := resolvedImportCache.Do(importKey, func() any {
                var r resolvedImport
-               if build.IsLocalImport(path) {
+               if cfg.ModulesEnabled {
+                       r.dir, r.path, r.err = modload.Lookup(parentPath, parentIsStd, path)
+               } else if build.IsLocalImport(path) {
                        r.dir = filepath.Join(parentDir, path)
                        r.path = dirToImportPath(r.dir)
-               } else if cfg.ModulesEnabled {
-                       r.dir, r.path, r.err = modload.Lookup(parentPath, parentIsStd, path)
                } else if mode&ResolveImport != 0 {
                        // We do our own path resolution, because we want to
                        // find out the key to use in packageCache without the
@@ -1119,6 +1119,7 @@ func dirAndRoot(path string, dir, root string) (string, string) {
        }
 
        if !str.HasFilePathPrefix(dir, root) || len(dir) <= len(root) || dir[len(root)] != filepath.Separator || path != "command-line-arguments" && !build.IsLocalImport(path) && filepath.Join(root, path) != dir {
+               debug.PrintStack()
                base.Fatalf("unexpected directory layout:\n"+
                        "       import path: %s\n"+
                        "       root: %s\n"+
@@ -2235,13 +2236,17 @@ func (p *Package) setBuildInfo() {
 
        var debugModFromModinfo func(*modinfo.ModulePublic) *debug.Module
        debugModFromModinfo = func(mi *modinfo.ModulePublic) *debug.Module {
+               version := mi.Version
+               if version == "" {
+                       version = "(devel)"
+               }
                dm := &debug.Module{
                        Path:    mi.Path,
-                       Version: mi.Version,
+                       Version: version,
                }
                if mi.Replace != nil {
                        dm.Replace = debugModFromModinfo(mi.Replace)
-               } else {
+               } else if mi.Version != "" {
                        dm.Sum = modfetch.Sum(module.Version{Path: mi.Path, Version: mi.Version})
                }
                return dm
@@ -2424,12 +2429,7 @@ func (p *Package) setBuildInfo() {
                appendSetting("vcs.modified", strconv.FormatBool(st.Uncommitted))
        }
 
-       text, err := info.MarshalText()
-       if err != nil {
-               setPkgErrorf("error formatting build info: %v", err)
-               return
-       }
-       p.Internal.BuildInfo = string(text)
+       p.Internal.BuildInfo = info.String()
 }
 
 // SafeArg reports whether arg is a "safe" command-line argument,