Documentation ¶
Index ¶
Constants ¶
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") // Forbidden licenses are forbidden to be used. Forbidden = Type("FORBIDDEN") )
License types
Variables ¶
This section is empty.
Functions ¶
func Find ¶
func Find(dir string, rootDir string, classifier Classifier) (string, error)
Find returns the 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 ¶
Classifier can detect the type of a software license.
func NewClassifier ¶
func NewClassifier(confidenceThreshold float64) (Classifier, error)
NewClassifier creates a classifier that requires a specified confidence threshold in order to return a positive license classification.
type GitRepo ¶
type GitRepo struct {
// contains filtered or unexported fields
}
GitRepo represents a Git repository that exists on disk locally.
func FindGitRepo ¶
FindGitRepo finds the Git repository that contains the specified filePath by searching upwards through the directory tree for a ".git" directory.
type Library ¶
type Library struct { // LicensePath is the path of the file containing the library's license. LicensePath 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 // 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 ¶
FileURL attempts to determine the URL for a file in this library using go module name and version.
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