Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
- index f2a2a60..ba8efd0 100644
- --- a/src/cmd/go/build.go
- +++ b/src/cmd/go/build.go
- @@ -586,7 +586,7 @@ func runInstall(cmd *Command, args []string) {
- switch {
- case p.gobinSubdir:
- errorf("go install: cannot install cross-compiled binaries when GOBIN is set")
- - case p.cmdline:
- + case p.Cmdline:
- errorf("go install: no install location for .go files listed on command line (GOBIN not set)")
- case p.ConflictDir != "":
- errorf("go install: no install location for %s: hidden by %s", p.Dir, p.ConflictDir)
- @@ -813,6 +813,7 @@ func goFilesPackage(gofiles []string) *Package {
- ctxt.ReadDir = func(string) ([]os.FileInfo, error) { return dirent, nil }
- var err error
- + path := dir
- if dir == "" {
- dir = cwd
- }
- @@ -824,7 +825,8 @@ func goFilesPackage(gofiles []string) *Package {
- bp, err := ctxt.ImportDir(dir, 0)
- pkg := new(Package)
- pkg.local = true
- - pkg.cmdline = true
- + pkg.Cmdline = true
- + pkg.Path = path
- stk.push("main")
- pkg.load(&stk, bp, err)
- stk.pop()
- diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go
- index 0c0cf07..1a8a2e6 100644
- --- a/src/cmd/go/pkg.go
- +++ b/src/cmd/go/pkg.go
- @@ -77,6 +77,10 @@ type Package struct {
- XTestGoFiles []string `json:",omitempty"` // _test.go files outside package
- XTestImports []string `json:",omitempty"` // imports from XTestGoFiles
- + // Additional information
- + Cmdline bool `json:",omitempty"` // defined by files listed on command line
- + Path string `json:",omitempty"` // original import path
- +
- // Unexported fields are not part of the public API.
- build *build.Package
- pkgdir string // overrides build.PkgDir
- @@ -90,7 +94,6 @@ type Package struct {
- external bool // synthesized external test package
- forceBuild bool // this package must be rebuilt
- forceLibrary bool // this package is a library (even if named "main")
- - cmdline bool // defined by files listed on command line
- local bool // imported via local path (./ or ../)
- localPrefix string // interpret ./ and ../ imports relative to this prefix
- exeName string // desired name for temporary executable
- @@ -1577,6 +1580,7 @@ var cmdCache = map[string]*Package{}
- // loadPackage accepts pseudo-paths beginning with cmd/ to denote commands
- // in the Go command directory, as well as paths to those directories.
- func loadPackage(arg string, stk *importStack) *Package {
- + path := arg
- if build.IsLocalImport(arg) {
- dir := arg
- if !filepath.IsAbs(dir) {
- @@ -1627,10 +1631,15 @@ func loadPackage(arg string, stk *importStack) *Package {
- bp, _ := buildContext.ImportDir(filepath.Join(cwd, arg), build.FindOnly)
- if bp.ImportPath != "" && bp.ImportPath != "." {
- arg = bp.ImportPath
- + if bp.Goroot && isStandardImportPath(bp.ImportPath) {
- + path = arg
- + }
- }
- }
- - return loadImport(arg, cwd, nil, stk, nil, 0)
- + pkg := loadImport(arg, cwd, nil, stk, nil, 0)
- + pkg.Path = path
- + return pkg
- }
- // packages returns the packages named by the
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement