1
0
mirror of https://github.com/golang/go synced 2024-09-30 14:38:33 -06:00

cmd/guru: fix guessImportPath for Windows

Import paths in Go use forward slashes, not the operating system's path separator.

Fixes golang/go#24699.
Fixes golang/go#23318.

Change-Id: I190224f6b7236e8ee19893f3589dd9686cbf116a
GitHub-Last-Rev: 751b29ca5f2e52ee1124c4baca6e45eecf4a3052
GitHub-Pull-Request: golang/tools#56
Reviewed-on: https://go-review.googlesource.com/c/151057
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Gordon Tyler 2019-02-23 03:21:59 +00:00 committed by Dmitri Shuralyov
parent 69f75a3b06
commit 2dc4ef2775

View File

@ -10,6 +10,7 @@ import (
"go/build"
"go/token"
"os"
"path"
"path/filepath"
"sort"
"strings"
@ -202,7 +203,7 @@ func guessImportPath(filename string, buildContext *build.Context) (srcdir, impo
if d >= 0 && d < minD {
minD = d
srcdir = gopathDir
importPath = strings.Join(segmentedAbsFileDir[len(segmentedAbsFileDir)-minD:], string(os.PathSeparator))
importPath = path.Join(segmentedAbsFileDir[len(segmentedAbsFileDir)-minD:]...)
}
}
if srcdir == "" {