Documentation ¶
Overview ¶
Package licenses provides some structures for handling and representing software licenses. It uses SPDX representations for part of it, because there doesn't seem to be a better alternative. It doesn't guarantee that it implements all of the SPDX spec. If there's an aspect which you think was mis-implemented or is missing, please let us know. XXX: Add a test to check if the license-list-data submodule is up-to-date!
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type License ¶
type License struct { // SPDX is the well-known SPDX ID for the license. SPDX string // Origin shows a different license provenance, and associated custom // name. It should probably be a "reverse-dns" style unique identifier. Origin string // Custom is a custom string that is a unique identifier for the license // in the aforementioned Origin namespace. Custom string }
License is a representation of a license. It's better than a simple SPDX ID as a string, because it allows us to store alternative representations to an internal or different representation, as well as any other information that we want to have associated here.
func StringToLicense ¶ added in v0.0.2
StringToLicense takes an input string and returns a license struct. This can handle both normal SPDX ID's and the origin strings in the `name(origin)` format. It rarely returns an error unless you pass it an obviously fake license identifier. TODO: add some tests
func StringsToLicenses ¶ added in v0.0.2
StringsToLicenses converts a list of input strings and converts them into the matching list of license structs. It accepts non-SPDX license names in the standard SPDX format of `name(origin)`.
func Union ¶ added in v0.0.2
Union returns the union of licenses in both input lists. It uses the pointers from the first list in the results. It does not try to remove duplicates so if either list has duplicates, you may end up with duplicates in the result. It uses the license Cmp method to determine equality.
type LicenseListSPDX ¶
type LicenseListSPDX struct { Version string `json:"licenseListVersion"` Licenses []*LicenseSPDX `json:"licenses"` }
LicenseListSPDX is modelled after the official SPDX licenses.json file.
var (
LicenseList LicenseListSPDX // this gets populated during init()
)
type LicenseSPDX ¶
type LicenseSPDX struct { // Reference is a link to the full license .json file. Reference string `json:"reference"` IsDeprecated bool `json:"isDeprecatedLicenseId"` DetailsURL string `json:"detailsUrl"` // ReferenceNumber is an index number for the license. I wouldn't // consider this to be stable over time. ReferenceNumber int64 `json:"referenceNumber"` // Name is a friendly name for the license. Name string `json:"name"` // LicenseID is the SPDX ID for the license. LicenseID string `json:"licenseId"` SeeAlso []string `json:"seeAlso"` IsOSIApproved bool `json:"isOsiApproved"` //IsDeprecated bool `json:"isDeprecatedLicenseId"` // appears again IsFSFLibre bool `json:"isFsfLibre"` Text string `json:"licenseText"` }
LicenseSPDX is modelled after the official SPDX license entries. It also includes fields from the referenced fields, which include the full text.
func ID ¶
func ID(spdx string) (*LicenseSPDX, error)
ID looks up the license from the imported list. Do not modify the result as it is the global database that everyone is using.