Skip to content

Commit

Permalink
Attempt to restore 1.3 and 1.4 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
kisielk committed Jul 10, 2016
1 parent abc3921 commit 54b5fb0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions go13.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
package gotool

import (
"go/build"
"path/filepath"
"runtime"
)

var gorootSrcPkg = filepath.Join(runtime.GOROOT(), "src", "pkg")

func shouldIgnoreImport(p *build.Package) bool {
return true
}
5 changes: 5 additions & 0 deletions go14.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
package gotool

import (
"go/build"
"path/filepath"
"runtime"
)

var gorootSrcPkg = filepath.Join(runtime.GOROOT(), "src")

func shouldIgnoreImport(p *build.Package) bool {
return true
}
16 changes: 16 additions & 0 deletions go15.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// +build go1.5
// +build !go1.4

This comment has been minimized.

Copy link
@dmitshur

dmitshur Jul 10, 2016

Contributor

I don't think this is right.

This build constraint says:

  • Package must be AT LEAST 1.5 or later,
  • AND, package must be 1.3 or OR OLDER.

In other words, it's never going to be true.

I think go15.go should have // +build go1.5 only, and go14.go should get a second constraint:

+build go1.4
+build !go1.5

Or an alternative single-line version of that:

+build go1.4,!go1.5

Which will make it apply to Go 1.4 only, as we want it to.

I can apply this fix to my #13 PR, if that's okay?

This comment has been minimized.

Copy link
@kisielk

kisielk Jul 10, 2016

Author Owner

hm yeah, I think you're right. Just add it to the PR then.

This comment has been minimized.


package gotool

import (
"go/build"
"path/filepath"
"runtime"
)

var gorootSrcPkg = filepath.Join(runtime.GOROOT(), "src", "pkg")

func shouldIgnoreImport(p *build.Package) bool {
return p == nil || len(p.InvalidGoFiles) == 0
}
2 changes: 1 addition & 1 deletion match.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func matchPackagesInFS(pattern string) []string {
// as not matching the pattern. Go 1.5 and earlier skipped, but that
// behavior means people miss serious mistakes.
// See golang.org/issue/11407.
if p, err := build.ImportDir(path, 0); err != nil && (p == nil || len(p.InvalidGoFiles) == 0) {
if p, err := build.ImportDir(path, 0); err != nil && shouldIgnoreImport(p) {
if _, noGo := err.(*build.NoGoError); !noGo {
log.Print(err)
}
Expand Down

0 comments on commit 54b5fb0

Please sign in to comment.