Documentation
¶
Overview ¶
Package lockfile provides mechanisms for creating and modifying shed lockfiles.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrIncorrectVersion = errors.Str("lockfile: incorrect version of tool")
ErrIncorrectVersion is returned when the version of a tool found is different then the version requested.
var ErrInvalidVersion = errors.Str("lockfile: tool has invalid version")
ErrInvalidVersion is returned when adding a tool to a lockfile that does not have a valid SemVer. The version in a lockfile must be an exact version, it cannot be a module query (ex: branch name or commit SHA) or a shorthand version.
var ErrMultipleTools = errors.Str("lockfile: multiple tools found with the same name")
ErrMultipleTools indicates that multiple tools with the same name were found in the lockfile.
var ErrNotFound = errors.Str("lockfile: tool not found")
ErrNotFound is returned when a tool is not found in a lockfile.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator allows for iteration over the tools within a Lockfile. An iterator provides two methods that can be used for iteration, Next and Value. Next advances the iterator to the next element and returns a bool indicating if it was successful. Value returns the value at the current index.
The iteration order over a lockfile is not specified and is not guaranteed to be the same from one iteration to the next. It is not safe to add or delete tools from a lockfile during iteration.
type Lockfile ¶
type Lockfile struct {
// contains filtered or unexported fields
}
Lockfile represents a shed lockfile. The lockfile is responsible for keeping track of installed tools as well as their versions so shed can always re-install the same version of each tool.
A zero value Lockfile is a valid empty lockfile ready for use.
func (*Lockfile) DeleteTool ¶
DeleteTool removes the given tool from the lockfile if it exists. If t.Version is not empty, the tool will only be deleted from the lockfile if it has the same version. If t.Version is empty, it will be deleted from the lockfile regardless of version.
func (*Lockfile) GetTool ¶
GetTool retrieves the tool with the given name from the lockfile. Name can either be the name of the tool itself (i.e. the name of the binary) or it can be the full import path.
If no tool is found, ErrNotFound is returned. If the name is a full import path and it contains a version, then the version will be checked against the tool found. If the versions do not match, then ErrIncorrectVersion will be returned along with the found version of the tool.
func (*Lockfile) Iter ¶
Iter creates a new Iterator that can be used to iterate over the tools in a Lockfile.