Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Commit

Permalink
FIX #37 Use absolute paths for searching in GOPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilchm committed Dec 13, 2016
1 parent 5c75f9e commit c91f7c2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"log"
"os"
"path/filepath"
"strings"

"github.com/jawher/mow.cli"
Expand Down Expand Up @@ -54,8 +55,12 @@ func currentPackage(goPath string) (string, error) {
}

for _, goPathDir := range strings.Split(goPath, ":") {
if strings.HasPrefix(currDir, goPathDir+"/src/") {
return strings.TrimPrefix(currDir, goPathDir+"/src/"), nil
goPathSrc, err := filepath.Abs(filepath.Join(goPathDir, "/src"))
if err != nil {
continue
}
if strings.HasPrefix(currDir, goPathSrc) {
return strings.TrimPrefix(currDir, goPathSrc+"/"), nil
}
}

Expand Down

0 comments on commit c91f7c2

Please sign in to comment.