Documentation ¶
Index ¶
- func StatusWithContext(ctx context.Context, l StatusListener) context.Context
- func Translate(ctx context.Context, m module.Module, ts []Translator) module.Module
- func UpdateStatus(ctx context.Context, t StatusType, msg string)
- type Finder
- type License
- type MockFinder
- type MockStatusListener
- type StatusListener
- type StatusType
- type Translator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StatusWithContext ¶
func StatusWithContext(ctx context.Context, l StatusListener) context.Context
StatusWithContext inserts a StatusListener into a context.
func Translate ¶
Translate translates the given module or returns the same module if no translation is necessary.
func UpdateStatus ¶
func UpdateStatus(ctx context.Context, t StatusType, msg string)
UpdateStatus updates the status of the listener (if any) in the given context.
Types ¶
type Finder ¶
type Finder interface { // License looks up the license for a given module. License(context.Context, module.Module) (*License, error) }
Finder implementations can find a license for a given module.
type License ¶
type License struct { Name string // Name is a human-friendly name like "MIT License" SPDX string // SPDX ID of the license, blank if unknown or unavailable }
License represents a software license.
func Find ¶
Find finds the license for the given module using a set of finders.
The finders are tried in the order given. The first finder to return a non-nil License without an error is returned. If a finder returns an error, other finders are still attempted. It is possible for a non-nil license to be returned WITH a non-nil error meaning a different lookup failed.
type MockFinder ¶
MockFinder is an autogenerated mock type for the Finder type
type MockStatusListener ¶
MockStatusListener is an autogenerated mock type for the StatusListener type
func (*MockStatusListener) UpdateStatus ¶
func (_m *MockStatusListener) UpdateStatus(t StatusType, msg string)
UpdateStatus provides a mock function with given fields: t, msg
type StatusListener ¶
type StatusListener interface { // UpdateStatus is called whenever there is an updated status message. // This function must not block, since this will block the actual // behavior of the license finder as well. If blocking behavior is // necessary, end users should use a channel internally to avoid it on // the function call. // // The message should be relatively short if possible (within ~50 chars) // so that it fits nicely on a terminal. It should be a basic status // update. UpdateStatus(t StatusType, msg string) }
StatusListener is called to update the status of a finder.
type StatusType ¶
type StatusType uint
StatusType is the type of status message, such as normal, error, warning.
const ( StatusUnknown StatusType = iota StatusNormal StatusWarning StatusError )
type Translator ¶
type Translator interface { // Translate takes a module and converts it into another module. // This is used to, for example, detect gopkg.in URLs as GitHub // repositories. Translate(context.Context, module.Module) (module.Module, bool) }
Translator implementations can convert one module path to another module path that is more suitable for license lookup.