// Identify returns the name and type of a license, given its file path.
// An empty license path results in an empty name and Unknown type.
Identify returns the name and type of a license, given its file path.
An empty license path results in an empty name and Unknown type.
// Identify returns the name and type of a license given its file path . // An empty license path results in an empty name and Unknown type .
func (c *googleClassifier) Identify(licensePath string) (string, Type, error) {
	if licensePath == "" {
		return "", Unknown, nil
	}
	content, err := ioutil.ReadFile(licensePath)
	if err != nil {
		return "", "", err
	}
	lines := strings.Split(string(content), "\n")
	if len(lines) > 0 && immuneLicenseRegexp.MatchString(lines[0]) {
		return "immune", Proprietary, nil
	}
	matches := c.classifier.MultipleMatch(string(content), true)
	if len(matches) == 0 {
		return "", "", fmt.Errorf("unknown license")
	}
	licenseName := matches[0].Name
	return licenseName, Type(licenseclassifier.LicenseType(licenseName)), nil
}
func ( c * googleClassifier ) Identify ( licensePath string ) ( string , Type , error ) { if licensePath == " " { return " " , Unknown , nil } content , err := ioutil . ReadFile ( licensePath ) if err != nil { return " " , " " , err } lines := strings . Split ( string ( content ) , " \n " ) if len ( lines ) > 0 && immuneLicenseRegexp . MatchString ( lines [ 0 ] ) { return " " , Proprietary , nil } matches := c . classifier . MultipleMatch ( string ( content ) , true ) if len ( matches ) == 0 { return " " , " " , fmt . Errorf ( " " ) } licenseName := matches [ 0 ] . Name return licenseName , Type ( licenseclassifier . LicenseType ( licenseName ) ) , nil }
Identify returns the name and type of a license, given its file path.
Identify returns the name and type of a license given its file path .