Documentation
¶
Index ¶
- type LicenseDetector
- type LicenseMatch
- type Normalizer
- func (n *Normalizer) GetSupportedLicenses() map[string]string
- func (n *Normalizer) IsSPDXValid(license string) bool
- func (n *Normalizer) Normalize(license string) string
- func (n *Normalizer) NormalizeMultiple(licenses []string) []string
- func (n *Normalizer) ParseLicenseExpression(expr string) []string
- func (n *Normalizer) ParseTOMLLicense(licenseStr string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LicenseDetector ¶
type LicenseDetector struct{}
LicenseDetector handles file-based license detection
func NewLicenseDetector ¶
func NewLicenseDetector() *LicenseDetector
NewLicenseDetector creates a new license detector
func (*LicenseDetector) AddLicensesToPayload ¶
func (d *LicenseDetector) AddLicensesToPayload(payload *types.Payload, dirPath string)
AddLicensesToPayload detects and adds licenses from the current directory to the payload
func (*LicenseDetector) DetectLicensesInDirectory ¶
func (d *LicenseDetector) DetectLicensesInDirectory(dirPath string) []LicenseMatch
DetectLicensesInDirectory detects licenses from LICENSE files in a directory Returns a list of detected licenses with metadata (confidence > 0.9)
type LicenseMatch ¶
LicenseMatch represents a detected license with metadata
type Normalizer ¶
type Normalizer struct {
// contains filtered or unexported fields
}
Normalizer handles SPDX-compliant license normalization
func NewNormalizer ¶
func NewNormalizer() *Normalizer
NewNormalizer creates a new license normalizer with comprehensive SPDX mappings
func (*Normalizer) GetSupportedLicenses ¶
func (n *Normalizer) GetSupportedLicenses() map[string]string
GetSupportedLicenses returns all supported SPDX license mappings
func (*Normalizer) IsSPDXValid ¶
func (n *Normalizer) IsSPDXValid(license string) bool
IsSPDXValid checks if a license string appears to be a valid SPDX identifier
func (*Normalizer) Normalize ¶
func (n *Normalizer) Normalize(license string) string
Normalize normalizes a license string to SPDX standard format
func (*Normalizer) NormalizeMultiple ¶
func (n *Normalizer) NormalizeMultiple(licenses []string) []string
NormalizeMultiple normalizes multiple licenses and removes duplicates
func (*Normalizer) ParseLicenseExpression ¶
func (n *Normalizer) ParseLicenseExpression(expr string) []string
ParseLicenseExpression parses license expressions like "MIT OR Apache-2.0" Returns individual licenses as a slice
func (*Normalizer) ParseTOMLLicense ¶
func (n *Normalizer) ParseTOMLLicense(licenseStr string) string
ParseTOMLLicense parses TOML license field and extracts the license text Handles formats like: license = "MIT", license = {text = "MIT"}