Documentation
¶
Index ¶
Constants ¶
const ( DefaultListURL = "https://spdx.org/licenses/licenses.json" DefaultDetailsURL = "https://spdx.org/licenses/%[1]s.json" )
Variables ¶
var DefaultClient = &Client{}
DefaultClient is the default Client used by the top-level functions List, License, etc.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // HTTP is the HTTP client to use for requests. If this is nil, then // a default new HTTP client will be used. HTTP *http.Client // ListURL and DetailsURL are the URLs for listing licenses and accessing // a single license, respectively. If these are not set, they will default // to the default values specified in constants (i.e. DefaultListURL). // // For DetailsURL, use the placeholder "%[1]s" to interpolate the SPDX ID. ListURL string DetailsURL string // contains filtered or unexported fields }
Client is an API client for accessing SPDX data.
Configure any fields on the struct prior to calling any functions. After calling functions, do not access the fields again.
The functions on Client are safe to call concurrently.
func (*Client) License ¶
func (c *Client) License(id string) (*LicenseInfo, error)
License returns the license by ID. This often includes more detailed information than List such as the full license text.
The ID is usually case sensitive. Please ensure the ID is set exactly to the SPDX ID, including casing.
If err == nil, then *License will always be non-nil.
func (*Client) List ¶
func (c *Client) List() (*LicenseList, error)
List returns the list of licenses.
If err == nil, then *LicenseList will always be non-nil.
type LicenseInfo ¶
type LicenseInfo struct { ID string `json:"licenseId"` Name string `json:"name"` Text string `json:"licenseText"` Deprecated bool `json:"isDeprecatedLicenseId"` OSIApproved bool `json:"isOsiApproved"` SeeAlso []string `json:"seeAlso"` }
LicenseInfo is a single software license.
Basic descriptions are documented in the fields below. For a full description of the fields, see the official SPDX specification here: https://github.com/spdx/license-list-data/blob/master/accessingLicenses.md
func License ¶
func License(id string) (*LicenseInfo, error)
License is the same as Client.License, but operates on DefaultClient.
type LicenseList ¶
type LicenseList struct { // Version is the raw version string of the license list. Version string `json:"licenseListVersion"` // Licenses is the list of known licenses. Licenses []*LicenseInfo `json:"licenses"` }
LicenseList is the structure for a list of licenses provided by the SPDX API
func List ¶
func List() (*LicenseList, error)
List is the same as Client.List, but operates on DefaultClient.
func (*LicenseList) License ¶
func (l *LicenseList) License(id string) *LicenseInfo
License looks up the license in the list with the given ID. If the license is not found, nil is returned.
Note that licenses in a LicenseList are usually missing fields such as Text. To fully populate a Licenese, call Client.Licence with the ID.