Skip to content

Commit bc489d0

Browse files
small Go 1.5 update
Skip a workaround that we no longer need.
1 parent ce88866 commit bc489d0

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

cmd.go

+9-11
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,10 @@ func doBuild(args []string) {
212212
tmpDir := generateSourceFiles(&conf, "build")
213213
tmpFile := filepath.Join(tmpDir, "godebug.-i.a.out")
214214

215-
// Run 'go build -i' once without changing the GOPATH.
216-
// This will recompile and install any out-of-date packages.
217-
// When we modify the GOPATH in the next invocation of the go tool, it will
218-
// not check if any of the uninstrumented dependencies are out-of-date.
219-
shellGo("", []string{"build", "-o", tmpFile, "-tags", *tags, "-i"}, goArgs)
215+
if doGopathWorkaround {
216+
// Rebuild stale packages, since this version of Go will not do so by default.
217+
shellGo("", []string{"build", "-o", tmpFile, "-tags", *tags, "-i"}, goArgs)
218+
}
220219

221220
if isPkg {
222221
goArgs = mapPkgsToTmpDir(goArgs)
@@ -248,12 +247,11 @@ func doRun(args []string) {
248247

249248
tmpDir := generateSourceFiles(&conf, "run")
250249

251-
// Run 'go build -i' once without changing the GOPATH.
252-
// This will recompile and install any out-of-date packages.
253-
// When we modify the GOPATH in the next invocation of the go tool, it will
254-
// not check if any of the uninstrumented dependencies are out-of-date.
255-
shellGo("", []string{"build", "-o", os.DevNull, "-tags", *tags, "-i"},
256-
gofiles)
250+
if doGopathWorkaround {
251+
// Rebuild stale packages, since this version of Go will not do so by default.
252+
shellGo("", []string{"build", "-o", os.DevNull, "-tags", *tags, "-i"},
253+
gofiles)
254+
}
257255

258256
// Run 'go build', then run the binary.
259257
// We do this rather than invoking 'go run' directly so we can implement

go_14.go

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// +build !go1.5
2+
3+
package main
4+
5+
// Prior to Go 1.5, the go tool would not rebuild stale package outside of the
6+
// current GOPATH directory. This is a problem for godebug, because it creates
7+
// temporary instrumented versions of packages in a separate directory from the
8+
// user's regular GOPATH. For versions of Go before 1.5, godebug needs to
9+
// work around this.
10+
//
11+
// See https://github.com/golang/go/issues/10509
12+
const doGopathWorkaround = true

go_15.go

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// +build go1.5
2+
3+
package main
4+
5+
// Prior to Go 1.5, the go tool would not rebuild stale package outside of the
6+
// current GOPATH directory. This is a problem for godebug, because it creates
7+
// temporary instrumented versions of packages in a separate directory from the
8+
// user's regular GOPATH. For versions of Go before 1.5, godebug needs to
9+
// work around this.
10+
//
11+
// See https://github.com/golang/go/issues/10509
12+
const doGopathWorkaround = false

0 commit comments

Comments
 (0)