Skip to content

Commit

Permalink
Search vendor directories when using import path
Browse files Browse the repository at this point in the history
  • Loading branch information
nkovacs committed Jun 23, 2017
1 parent c9ddd61 commit ee3dc58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions locator/locator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func GetInterfaceFromFilePath(interfaceName, filePath string) (*model.InterfaceT
return nil, err
}

vendorPaths, err := vendorPathsForDirPath(dirPath)
vendorPaths, err := VendorPathsForDirPath(dirPath)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -145,7 +145,7 @@ func importPathForDirPath(sourcePath string) (string, error) {
return "", fmt.Errorf("Path '%s' is not on GOPATH", sourcePath)
}

func vendorPathsForDirPath(dirPath string) ([]string, error) {
func VendorPathsForDirPath(dirPath string) ([]string, error) {
dirPath, err := filepath.Abs(dirPath)
if err != nil {
return nil, err
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ func generateFake(interfaceName, sourcePackageDir, importPath, outputPath, desti
var err error
var iface *model.InterfaceToFake
if sourcePackageDir == "" {
iface, err = locator.GetInterfaceFromImportPath(interfaceName, importPath)
var vendorPaths []string
vendorPaths, err = locator.VendorPathsForDirPath(".")
if err == nil {
iface, err = locator.GetInterfaceFromImportPath(interfaceName, importPath, vendorPaths...)
}
} else {
iface, err = locator.GetInterfaceFromFilePath(interfaceName, sourcePackageDir)
}
Expand Down

0 comments on commit ee3dc58

Please sign in to comment.