package licenses

Import Path
	golang.org/x/pkgsite/internal/licenses (on go.dev)

Dependency Relation
	imports 15 packages, and imported by 5 packages

Involved Source Files exceptions.gen.go exceptions.go Package licenses detects licenses and determines whether they are redistributable. The functions in this package do not return errors; instead, they log any problems they encounter and fail closed by reporting that the module or package is not redistributable. Example (modproxy): d := licenses.NewDetector(modulePath, version, zipReader, log.Infof) modRedist := d.ModuleIsRedistributable() Example (discovery): d := licenses.NewDetector(modulePath, version, zipReader, log.Infof) modRedist := d.ModuleIsRedistributable() lics := d.AllLicenses() pkgRedist, pkgMetas := d.PackageInfo(pkgSubdir)
Package-Level Type Names (total 5, all are exported)
/* sort exporteds by: | */
AcceptedLicenseInfo describes a license that is accepted by the discovery site. Name string URL string func AcceptedLicenses() []AcceptedLicenseInfo
A Detector detects licenses in a module and its packages. AllLicenses returns all the licenses detected in the entire module, including package licenses. Files returns a list of license files from the zip. The which argument determines the location of the files considered. ModuleIsRedistributable reports whether the given module is redistributable. ModuleLicenses returns the licenses that apply to the module. PackageInfo reports whether the package at dir, a directory relative to the module root, is redistributable. It also returns all the licenses that apply to the package. func NewDetector(modulePath, version string, zr *zip.Reader, logf func(string, ...interface{})) *Detector
A License is a classified license file path and its contents. Contents []byte Metadata *Metadata Metadata.Coverage licensecheck.Coverage FilePath is the '/'-separated path to the license file in the module zip, relative to the contents directory. The output of oldlicensecheck.Cover. Types is the set of license types, as determined by the licensecheck package. RemoveNonRedistributableData methods removes the license contents if the license is non-redistributable. func (*Detector).AllLicenses() []*License func (*Detector).ModuleLicenses() []*License func (*Detector).PackageInfo(dir string) (isRedistributable bool, lics []*License) func golang.org/x/pkgsite/internal/testing/sample.Licenses() []*License func golang.org/x/pkgsite/internal/testing/sample.AddLicense(m *internal.Module, lic *License) func golang.org/x/pkgsite/internal/testing/sample.ReplaceLicense(m *internal.Module, lic *License) var golang.org/x/pkgsite/internal/testing/sample.NonRedistributableLicense *License
Metadata holds information extracted from a license file. Coverage licensecheck.Coverage FilePath is the '/'-separated path to the license file in the module zip, relative to the contents directory. The output of oldlicensecheck.Cover. Types is the set of license types, as determined by the licensecheck package. func golang.org/x/pkgsite/internal/testing/sample.LicenseMetadata() []*Metadata
WhichFiles describes which files from the zip should be returned by Detector.Files. func (*Detector).Files(which WhichFiles) []*zip.File const AllFiles const NonRootFiles const RootFiles
Package-Level Functions (total 13, in which 4 are exported)
AcceptedLicenses returns a sorted slice of license types that are accepted as redistributable. Its result is intended to be displayed to users.
DetectFile return the set of license types for the given file contents. It also returns the licensecheck coverage information. The filename is used solely for logging.
NewDetector returns a Detector for the given module and version. zr should be the zip file for that module and version. logf is for logging; if nil, no logging is done.
Redistributable reports whether the set of license types establishes that a module or package is redistributable. All the licenses we see that are relevant must be redistributable, and we must see at least one such license.
Package-Level Variables (total 13, in which 2 are exported)
OmitExceptions causes the list of exceptions to be omitted from license detection. It is intended only to speed up testing, and must be set before the first use of this package.
Package-Level Constants (total 73, in which 3 are exported)
All files; the union of root and non-root.
Only files that are not in the root directory.
Only files from the root (contents) directory.