licenses

package
v2.0.0-dev.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: Apache-2.0 Imports: 16 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")
	// 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

type Classifier interface {
	Identify(licensePath string) (string, Type, error)
}

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

func FindGitRepo(filePath string) (*GitRepo, error)

FindGitRepo finds the Git repository that contains the specified filePath by searching upwards through the directory tree for a ".git" directory.

func (*GitRepo) FileURL

func (g *GitRepo) FileURL(filePath string, remote string) (*url.URL, error)

FileURL returns the URL of a file stored in a Git repository. It uses the URL of the specified Git remote repository to construct this URL. It supports repositories hosted on github.com, bitbucket.org and googlesource.com.

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, 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, 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

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 (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