-
Notifications
You must be signed in to change notification settings - Fork 124
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
Libraries function returns non-licensed vendored package as the package with LICENSE from root project #143
Comments
If the vendor folder is not modified, a simple workaround can be:
|
vendored modules do not have full metadata, as far as I know, this is working as intended. |
This seems unexpected, can we infer a vendor dir and set a correct root package folder? Looks like you already did some investigations, contribution welcomed! |
There were some special handling for vendored packages in go-licenses/licenses/library.go Line 152 in 5eedde1
You might consider doing a similar check and infer root path of package. |
I took a pass at fixing this after running into something similar would appreciate any feedback and other thoughts/issues I may fully understand. #178 |
Steps to reproduce:
go mod vendor
to place this package inside vendor foldergo-licenses report
orgo-licenses check
on your project. The command lists external package as package without a license (as it should be)go-licenses report
orgo-licenses check
on your project again. Now commands consider external package as having LICENSE from the root project folder:go-licenses check
doesn't fire an error andgo-licenses report
doesn't list external package at all (considering this as the part of root project).I guess it's because when
Libraries
function callsFind
function, it passesp.Module.Dir
as rootDir (which is nil for vendored packages for some reason) and thenFind
doesrootDir, err = filepath.Abs(rootDir)
, nil turns into working directory (root package folder) andfindUpwards
looks for license file until it finds it in root package folder.The text was updated successfully, but these errors were encountered: