Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search vendor directories when using import path #76

Closed
wants to merge 1 commit into from

Conversation

nkovacs
Copy link
Contributor

@nkovacs nkovacs commented Jun 23, 2017

Fixes #75

@@ -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(".")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like this could call to check for vendor paths could easily done inside the call to GetInterfaceFromImportPath. I think that would simplify this code here in main.go, which we should absolutely do, since it's not tested by unit tests.

In general, if you're calling multiple methods to an object (or in this case, a package) and then passing the results from one directly into the other, it's a case of the abstraction you've created leaking, and not having a well defined interface for how to use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but I wasn't sure how to do that.

I would rename GetInterfaceFromImportPath to an unexported function, change all calls to that, then create another GetInterfaceFromImportPath without the last parameter, and call locator.VendorPathsForDirPath(".") before calling the unexported function.

There's also another PR that changes these functions, so that complicates things a bit.

@joefitzgerald
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants