google / go-licenses

A lightweight tool to report on the licenses used by a Go package and its dependencies. Highlight! Versioned external URL to licenses can be found at the same time.
Apache License 2.0
833 stars 125 forks source link

Improper `isStdlib()` path check using `strings.HasPrefix()` #147

Closed jingyuanliang closed 2 years ago

jingyuanliang commented 2 years ago

I have a setup where my GOROOT is /usr/local/go and source files are stored under /usr/local/google. go-licenses doesn't output anything in this case. I've traced it down and it's due to https://github.com/google/go-licenses/blob/13c8b648ff73469070f7f19c53dfbb88434370c4/licenses/library.go#L289 where build.Default.GOROOT got /usr/local/go and pkg.GoFiles[0] got /usr/local/google/... so it thinks everything is stdlib, then skips all of them.

Bobgy commented 2 years ago

looks like we can just check prefix /usr/local/go/ instead

Bobgy commented 2 years ago

Duplicate of https://github.com/google/go-licenses/issues/38