license

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

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

type LicenseMatch struct {
	License    string
	Confidence float32
	File       string
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL