The license discovery is an open-source lib that can analyze license text to determine what type of license it contains
It searches for license texts in a file and compares them to an archive of known licenses This library encapsulate logic from 2 best licenses detection libraries :
License Classifier : https://github.com/google/licenseclassifier
go-license-detector : https://github.com/src-d/go-license-detector
In Addition, this library uses : checksum-based cache to have better performance detection of licenses which already been met analyzed pom file to detect licenses which presented in the pom as a comment.
go get github.com/chen-keinan/go-license-discovery
- License.txt
- License.md
- License within pom file comments
- Copyright
- Multi license file
copy licenses.db (located under pkg/matcher/licenses/licenses.db) file to <licenses folder>
func main() {
lm, err := matcher.NewLicenseMatcher("/licenses/")
if err != nil {
fmt.Print(err.Error())
}
lic:=lm.matcher.GetPomCommentLicense(pomFile)
fmt.Print(lic)
}
import (
"fmt"
"github.com/chen-keinan/go-license-discovery/matcher"
)
func main() {
lm, err := matcher.NewLicenseMatcher("/licenses/")
if err != nil {
fmt.Print(err.Error())
}
matchedLicenses:=lm.MatchLicenseTxt("LICENSE.md")
fmt.Print(matchedLicenses)
}