Merge pull request #81 from IncSW/fix-parser-windows

Fix parser for windows
This commit is contained in:
Victor Starodub
2016-12-07 01:33:15 +04:00
committed by GitHub
+6 -2
View File
@@ -11,7 +11,7 @@ func normalizePath(path string) string {
return strings.Replace(path, "\\", "/", -1)
}
func getPkgPath(fname string) (string, error) {
func getPkgPath(fname string, isDir bool) (string, error) {
if !path.IsAbs(fname) {
pwd, err := os.Getwd()
if err != nil {
@@ -25,7 +25,11 @@ func getPkgPath(fname string) (string, error) {
for _, p := range strings.Split(os.Getenv("GOPATH"), ";") {
prefix := path.Join(normalizePath(p), "src") + "/"
if rel := strings.TrimPrefix(fname, prefix); rel != fname {
return path.Dir(rel), nil
if !isDir {
return path.Dir(rel), nil
} else {
return path.Clean(rel), nil
}
}
}