licenses

package
v0.0.0-...-ec48b64 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Unknown license type.
	Unknown = Type("")
	// Restricted licenses require mandatory source distribution if we ship a
	// product that includes third-party code protected by such a license.
	Restricted = Type("restricted")
	// Reciprocal licenses allow usage of software made available under such
	// licenses freely in *unmodified* form. If the third-party source code is
	// modified in any way these modifications to the original third-party
	// source code must be made available.
	Reciprocal = Type("reciprocal")
	// Notice licenses contain few restrictions, allowing original or modified
	// third-party software to be shipped in any product without endangering or
	// encumbering our source code. All of the licenses in this category do,
	// however, have an "original Copyright notice" or "advertising clause",
	// wherein any external distributions must include the notice or clause
	// specified in the license.
	Notice = Type("notice")
	// Permissive licenses are even more lenient than a 'notice' license.
	// Not even a copyright notice is required for license compliance.
	Permissive = Type("permissive")
	// Unencumbered covers licenses that basically declare that the code is "free for any use".
	Unencumbered = Type("unencumbered")

	ByExceptionOnly = Type("byExceptionOnly")
	// Forbidden licenses are forbidden to be used.
	Forbidden = Type("forbidden")
)

License types

Variables

This section is empty.

Functions

func FindCandidates

func FindCandidates(dir string, rootDir string) ([]string, error)

FindCandidates returns the candidate file path of the license for this package.

dir is path of the directory where we want to find a license. rootDir is path of the module containing this package. Find will not search out of the rootDir.

Types

type Classifier

type Classifier interface {
	Identify(licensePath string) ([]License, error)
}

Classifier can detect the type of a software license.

func NewClassifier

func NewClassifier() (Classifier, error)

NewClassifier creates a classifier

type Library

type Library struct {
	// LicenseFile is the path of the file containing the library's license.
	LicenseFile string
	// Packages contains import paths for Go packages in this library.
	// It may not be the complete set of all packages in the library.
	Packages []string

	// List of licenses for found at the LicenseFile.
	Licenses []License
	// contains filtered or unexported fields
}

Library is a collection of packages covered by the same license file.

func Libraries

func Libraries(ctx context.Context, classifier Classifier, includeTests bool, ignoredPaths []string, importPaths ...string) ([]*Library, error)

Libraries returns the collection of libraries used by this package, directly or transitively. A library is a collection of one or more packages covered by the same license file. Packages not covered by a license will be returned as individual libraries. Standard library packages will be ignored.

func (*Library) FileURL

func (l *Library) FileURL(ctx context.Context, cl *source.Client, filePath string) (string, error)

FileURL attempts to determine the URL for a file in this library using go module name and version.

func (*Library) Name

func (l *Library) Name() string

Name is the common prefix of the import paths for all of the packages in this library.

func (*Library) String

func (l *Library) String() string

func (*Library) Version

func (l *Library) Version() string

type License

type License struct {
	Name string
	Type Type
}

type LicenseRestrictiveness

type LicenseRestrictiveness string
const (
	RestrictionsShareLicense LicenseRestrictiveness = "ShareLicense"
	RestrictionsShareCode    LicenseRestrictiveness = "ShareCode"
	RestrictionsUnknown      LicenseRestrictiveness = "Unknown"
	RestrictionsNotAllowed   LicenseRestrictiveness = "NotAllowed"
)

func LicenseTypeRestrictiveness

func LicenseTypeRestrictiveness(licenseTypes ...Type) LicenseRestrictiveness

type Module

type Module struct {
	// Differences from packages.Module:
	// * Replace field is removed, it's only an implementation detail in this package.
	//   If a module is replaced, we'll directly return the replaced module.
	// * Version field +incompatible suffix is trimmed.
	// * Main, ModuleError, Time, Indirect, GoMod, GoVersion fields are removed, because they are not used.
	Path    string // module path
	Version string // module version
	Dir     string // directory holding files for this module, if any
}

Module provides module information for a package.

type PackagesError

type PackagesError struct {
	// contains filtered or unexported fields
}

PackagesError aggregates all Packages[].Errors into a single error.

func (PackagesError) Error

func (e PackagesError) Error() string

type Type

type Type string

Type identifies a class of software license.

func LicenseType

func LicenseType(license string) Type

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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