Skip to content

The license discovery is an open-source lib and set of tools that can analyze license text to determine what type of license it contains.

License

Notifications You must be signed in to change notification settings

chen-keinan/go-license-discovery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Report Card License test coverage badge Gitter


lic_disc.png logo

go-license-discovery

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.

Installation

go get github.com/chen-keinan/go-license-discovery

Supported Licenses

  • License.txt
  • License.md
  • License within pom file comments
  • Copyright
  • Multi license file

Usage :

Copy licenses.db file:

copy licenses.db (located under pkg/matcher/licenses/licenses.db) file to <licenses folder>

Extract License from pom file comments

func main() {
    lm, err := matcher.NewLicenseMatcher("/licenses/")
        if err != nil {
	        fmt.Print(err.Error())
	}
    lic:=lm.matcher.GetPomCommentLicense(pomFile)
    fmt.Print(lic)
  }

Example:

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)
}

About

The license discovery is an open-source lib and set of tools that can analyze license text to determine what type of license it contains.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published