Documentation ¶
Overview ¶
Package tool defines the tool.Tool type which allows for the manipulation of various properties of a tool.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tool ¶
type Tool struct { // ImportPath is the Go import path for the tool. // This includes the full path to the tool, not just the module. // Ex: For the stringer tool the import path is // golang/x/tools/cmd/stringer not golang/x/tools. ImportPath string // The version of the tool. This correspeonds to the version of // the Go module the tool belongs to. If version is empty, // it signifies that the latest version is desired where allowed. Version string }
Tool represents a tool managed by shed. In most cases this corresponds to a Go module.
func Parse ¶
Parse parses the given tool name and returns a tool containing the import path and version. name must be a valid import path and a version with the format 'IMPORT_PATH@VERSION'. This format is the same as what would be passed to a command like 'go get'. The version must be a valid semantic version and it must be prefixed with 'v' (ex: 'v1.2.3'). If a shorthand semantic version is used, it will be canonicalized (ex: 'v1' will become 'v1.0.0').
func ParseLax ¶
ParseLax is like Parse but does not check that the version is a valid semantic version. It is used when downloading and resolving tools using 'go get'. This is because go get allows module queries, which is where a version is resolved based on a branch name, commit SHA, version range, etc. See https://golang.org/cmd/go/#hdr-Module_queries for more details on module queries. Unlike Parse, ParseLax will not canonicalize shorthand semantic verions and will instead leave them as is.
ParseLax allows the version to be omitted in which case it is assumed to mean the latest version. That is, 'golang/x/tools/cmd/stringer' is functionally equivalent to 'golang/x/tools/cmd/stringer@latest'.
func (Tool) BinaryFilepath ¶
BinaryFilepath returns the relative OS filesystem path to the tool binary. This is the Filepath joined with the Name.
func (Tool) Filepath ¶
Filepath returns the relative OS filesystem path represented by this tool. The escape rules required for import paths are followed. For details on escaped paths see: https://pkg.go.dev/golang.org/x/mod@v0.4.0/module#hdr-Escaped_Paths
func (Tool) HasSemver ¶
HasSemver reports whether t.Version is a valid semantic version. HasSemver requires t.Version to be a full semantic version. It does not allow shorthands like vMAJOR or vMAJOR.MINOR.
func (Tool) Module ¶
Module returns the module name suitable for commands like 'go get'. This is the import path plus the version, if it exists, with the format 'IMPORT_PATH@VERSION'. If Version is empty, Module just returns ImportPath.