Advertisement
Guest User

Untitled

a guest
Feb 16th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.14 KB | None | 0 0
  1. diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
  2. index f2a2a60..ba8efd0 100644
  3. --- a/src/cmd/go/build.go
  4. +++ b/src/cmd/go/build.go
  5. @@ -586,7 +586,7 @@ func runInstall(cmd *Command, args []string) {
  6.             switch {
  7.             case p.gobinSubdir:
  8.                 errorf("go install: cannot install cross-compiled binaries when GOBIN is set")
  9. -           case p.cmdline:
  10. +           case p.Cmdline:
  11.                 errorf("go install: no install location for .go files listed on command line (GOBIN not set)")
  12.             case p.ConflictDir != "":
  13.                 errorf("go install: no install location for %s: hidden by %s", p.Dir, p.ConflictDir)
  14. @@ -813,6 +813,7 @@ func goFilesPackage(gofiles []string) *Package {
  15.     ctxt.ReadDir = func(string) ([]os.FileInfo, error) { return dirent, nil }
  16.  
  17.     var err error
  18. +   path := dir
  19.     if dir == "" {
  20.         dir = cwd
  21.     }
  22. @@ -824,7 +825,8 @@ func goFilesPackage(gofiles []string) *Package {
  23.     bp, err := ctxt.ImportDir(dir, 0)
  24.     pkg := new(Package)
  25.     pkg.local = true
  26. -   pkg.cmdline = true
  27. +   pkg.Cmdline = true
  28. +   pkg.Path = path
  29.     stk.push("main")
  30.     pkg.load(&stk, bp, err)
  31.     stk.pop()
  32. diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go
  33. index 0c0cf07..1a8a2e6 100644
  34. --- a/src/cmd/go/pkg.go
  35. +++ b/src/cmd/go/pkg.go
  36. @@ -77,6 +77,10 @@ type Package struct {
  37.     XTestGoFiles []string `json:",omitempty"` // _test.go files outside package
  38.     XTestImports []string `json:",omitempty"` // imports from XTestGoFiles
  39.  
  40. +   // Additional information
  41. +   Cmdline bool   `json:",omitempty"` // defined by files listed on command line
  42. +   Path    string `json:",omitempty"` // original import path
  43. +
  44.     // Unexported fields are not part of the public API.
  45.     build        *build.Package
  46.     pkgdir       string // overrides build.PkgDir
  47. @@ -90,7 +94,6 @@ type Package struct {
  48.     external     bool                 // synthesized external test package
  49.     forceBuild   bool                 // this package must be rebuilt
  50.     forceLibrary bool                 // this package is a library (even if named "main")
  51. -   cmdline      bool                 // defined by files listed on command line
  52.     local        bool                 // imported via local path (./ or ../)
  53.     localPrefix  string               // interpret ./ and ../ imports relative to this prefix
  54.     exeName      string               // desired name for temporary executable
  55. @@ -1577,6 +1580,7 @@ var cmdCache = map[string]*Package{}
  56.  // loadPackage accepts pseudo-paths beginning with cmd/ to denote commands
  57.  // in the Go command directory, as well as paths to those directories.
  58.  func loadPackage(arg string, stk *importStack) *Package {
  59. +   path := arg
  60.     if build.IsLocalImport(arg) {
  61.         dir := arg
  62.         if !filepath.IsAbs(dir) {
  63. @@ -1627,10 +1631,15 @@ func loadPackage(arg string, stk *importStack) *Package {
  64.         bp, _ := buildContext.ImportDir(filepath.Join(cwd, arg), build.FindOnly)
  65.         if bp.ImportPath != "" && bp.ImportPath != "." {
  66.             arg = bp.ImportPath
  67. +           if bp.Goroot && isStandardImportPath(bp.ImportPath) {
  68. +               path = arg
  69. +           }
  70.         }
  71.     }
  72.  
  73. -   return loadImport(arg, cwd, nil, stk, nil, 0)
  74. +   pkg := loadImport(arg, cwd, nil, stk, nil, 0)
  75. +   pkg.Path = path
  76. +   return pkg
  77.  }
  78.  
  79.  // packages returns the packages named by the
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement