licenseclassifier
licenseclassifier copied to clipboard
Trying to vendor go-licenses, which uses this, fails because the license DB is not vendored.
I see how this is trying to be very clever and find the license DB in its own source code path.
This totally breaks down in the face of Go's vendoring, which elides directories that do not have linked Go code in them.
So....ideas? Wouldn't it be better to embed the DB into the binary and make it self contained?
The licenseclassifier itself was fixed with this commit
The go-licenses package needs to be updated to get this change; I've sent a pull request to get this resolved.
Does that work with vendoring? I thought vendoring would exclude a package that was not reachable from the main package.
Indeed:
$ cat main.go
package main
import "github.com/google/licenseclassifier"
func main() {
x := licenseclassifier.License{}
_ = x
}
$ go mod init example.com/foo
go: creating new go.mod: module example.com/foo
go: to add module requirements and sums:
go mod tidy
$ go mod tidy
go: finding module for package github.com/google/licenseclassifier
go: found github.com/google/licenseclassifier in
github.com/google/licenseclassifier v0.0.0-20210324170212-2c2d728dc0d7
$ go mod vendor
$ find vendor/github.com/google/licenseclassifier/ -type d
vendor/github.com/google/licenseclassifier/
vendor/github.com/google/licenseclassifier/stringclassifier
vendor/github.com/google/licenseclassifier/stringclassifier/searchset
vendor/
github.com/google/licenseclassifier/stringclassifier/searchset/tokenizer
vendor/github.com/google/licenseclassifier/stringclassifier/internal
vendor/github.com/google/licenseclassifier/stringclassifier/internal/pq
vendor/github.com/google/licenseclassifier/internal
vendor/github.com/google/licenseclassifier/internal/sets
Empirically you need that dummy.go to not have a build tag and to export some symbol which is used by the rest of the lib. I tried it by mocking up github.com/thockin/vendortest
$ cat licenses/dummy.go
// Placeholder, allows others to pull in the licenses.db file via go.mod.
package licenses
var Dummy bool
$ cat top.go
package vendortest
import "github.com/thockin/vendortest/licenses"
type Top struct{}
var Dummy = licenses.Dummy
Probably using a type definition and an unexported alias would be even less impactful?
On Wed, Mar 24, 2021 at 10:24 AM Bill Neubauer @.***> wrote:
The licenseclassifier itself was fixed with this commit https://github.com/google/licenseclassifier/commit/df6aa8a2788bdf5ac382148c2453a407a29819b8
The go-licenses package needs to be updated to get this change; I've sent a pull request https://github.com/google/go-licenses/pull/57 to get this resolved.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/google/licenseclassifier/issues/27#issuecomment-806015845, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKWAVD2EYNY5XLW7NGI7DLTFIN6NANCNFSM4ZPTENUQ .
See https://github.com/google/licenseclassifier/pull/32 for a change to this lib, which (when updated in go-licenses) should support being vendored.
@thockin Looks like this issue can be closed