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

check package existence with govendor if installed #1828

Closed
wants to merge 1 commit into from

Conversation

genzj
Copy link

@genzj genzj commented May 15, 2018

also take the vendor dir into consider at command completing

try to fix #1709

consider the vendor dir in completion
@bhcleek
Copy link
Collaborator

bhcleek commented May 15, 2018

The problem this PR attempts to solve is not specific to govendor. The right solution to the problem is to parse the output of go list correctly.

From https://golang.org/cmd/go/#hdr-Vendor_Directories:

Packages stored in vendor directories report an ImportPath that includes the path to the vendor directory (for example, "d/vendor/p" instead of "p"), so that the ImportPath uniquely identifies a given copy of a package. The Imports, Deps, TestImports, and XTestImports lists also contain these expanded imports paths. See golang.org/s/go15vendor for more about vendoring.

@bhcleek bhcleek closed this May 15, 2018
@genzj
Copy link
Author

genzj commented May 16, 2018

@bhcleek but the output of go list some/dep/package doesn't return a line. do you mean the call should be go list proj/vendor/some/dep/package instead?

@bhcleek
Copy link
Collaborator

bhcleek commented May 16, 2018

To find a package that's only in a vendor directory, the vendor directories in each of the parent directories would need to be searched. govendor isn't needed to do that.

@genzj
Copy link
Author

genzj commented May 16, 2018

@bhcleek I understood the govender isn't needed for that, I think you made the point really clear. I just want to know the preferred methodology so that I may be able to help. By

the vendor directories in each of the parent directories would need to be searched

do you mean searching by go list with specific arguments/options, by other go xxx commands or by walking/globing in different directories with vimscript?

I don't mean any step-by-step solution. just let me know the preferred or ideal way. I will do further research and test.

you may have noticed i sent same pr years ago, but no more feedback due to busy project schedule that makes it impossible to digging on this problem so we continued the go vendor way. Since it can lock the dependency versions and isolate different projects, glide/go vendor mean a lot to me. I believe so as to many gophers. So I hope I can make even a small contribution to this issue, not only a private workaround patch.

thanks a lot.

@bhcleek
Copy link
Collaborator

bhcleek commented May 16, 2018

Assuming the current file is within GOPATH, I think the right solution would be to walk the directories up to the src that's in GOPATH, looking for vendor directory. For each vendor directory, if go list $relative_dir_path/vendor/$pkg returns 0, then the package exists.

@bhcleek bhcleek reopened this May 16, 2018
@genzj
Copy link
Author

genzj commented May 16, 2018

@bhcleek good one! thanks! I'll try that.

bhcleek added a commit that referenced this pull request May 22, 2018
bhcleek added a commit that referenced this pull request May 22, 2018
@bhcleek
Copy link
Collaborator

bhcleek commented Aug 25, 2018

Closing due to inactivity.

@bhcleek bhcleek closed this Aug 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GoTestFunc fail with vendored dependency
2 participants