licenses

package
v0.0.0-...-4b016c7 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 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")
	// Forbidden licenses are forbidden to be used.
	Forbidden = Type("FORBIDDEN")
)

License types

Variables

This section is empty.

Functions

func Find

func Find(dir string, classifier Classifier) (string, error)

Find returns the file path of the license for this package.

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
}

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

func Libraries

func Libraries(ctx context.Context, classifier Classifier, 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(filePath string) (*url.URL, error)

FileURL attempts to determine the URL for a file in this library. This only works for certain supported package prefixes, such as github.com, bitbucket.org and googlesource.com. Prefer GitRepo.FileURL() if possible.

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