diff --git a/imports/fix.go b/imports/fix.go index f2fec885..880c1690 100644 --- a/imports/fix.go +++ b/imports/fix.go @@ -827,11 +827,15 @@ func canUse(filename, dir string) bool { // or bar/vendor or bar/internal. // After stripping all the leading ../, the only okay place to see vendor or internal // is at the very beginning of the path. - abs, err := filepath.Abs(filename) + absfile, err := filepath.Abs(filename) if err != nil { return false } - rel, err := filepath.Rel(abs, dir) + absdir, err := filepath.Abs(dir) + if err != nil { + return false + } + rel, err := filepath.Rel(absfile, absdir) if err != nil { return false } diff --git a/imports/fix_test.go b/imports/fix_test.go index 7c7018e9..e1179e9c 100644 --- a/imports/fix_test.go +++ b/imports/fix_test.go @@ -829,7 +829,7 @@ func TestFixImports(t *testing.T) { func TestImportSymlinks(t *testing.T) { switch runtime.GOOS { case "windows", "plan9": - t.Skip("skipping test on %q as there are no symlinks", runtime.GOOS) + t.Skipf("skipping test on %q as there are no symlinks", runtime.GOOS) } newGoPath, err := ioutil.TempDir("", "symlinktest")