Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinTool ¶
type BinTool struct {
// contains filtered or unexported fields
}
BinTool represents a single binary tool/versioncmd combination with the information needed to check and/or install the tool if desired.
The struct provides a set of utilities for checking the existence of a valid versioncmd of the command and installing the command in a way that is scoped to the project at hand, if desired.
func Must ¶
Must provides a utility for asserting that methods returning a BinTool and an error have no error. If there is an error, this call will panic.
func New ¶
New initializes a BinTool with the provided command, versioncmd, and download url. Additional options may be provided to configure things such as the versioncmd test command, file extensions and folder containing the binary tool.
The command, url, and versioncmd command may all use text templates to define their formats. If any of these templates fails to compile or evaluate, this call will return an error.
func NewGo ¶
NewGo initializes a BinTool with the provided go package and versioncmd. Additional options may be provided to configure things such as the versioncmd test command and folder containing the binary tool.
func (*BinTool) Ensure ¶
Ensure checks to see if a valid versioncmd of the tool is installed, and downloads/installs it if it isn't already.
func (*BinTool) Install ¶
Install unconditionally downloads and installs the tool to the configured folder.
If you don't want to download the tool every time, you may prefer Ensure() instead.
func (*BinTool) IsInstalled ¶
IsInstalled checks whether the correct versioncmd of the tool is currently installed as defined by the versioncmd command.
type Option ¶
Option configures a BinTool with optional settings.
func WithArchiveExt ¶
WithArchiveExt defines a custom extension to use when identifying an archive via the ArchiveExt template variable. The default archive extension is .tar.gz except for Windows, where it is .zip.
func WithBinExt ¶
WithBinExt defines a custom extension to use when identifying a binary executable via the BinExt template variable. The default binary extension is empty for all operating systems except Windows, where it is .exe.
func WithFolder ¶
WithFolder defines a custom folder path where the tool is expected to exist and where it should be installed if desired. Paths will be normalized to the operating system automatically, so unix-style paths are recommended.
func WithVersionCmd ¶
WithVersionCmd defines a custom command used to test the versioncmd of the command for purposes of determining if the command is installed. The provided command is a template that can use any of the template parameters that are available to the url. If no command is provided, the versioncmd check will be skipped.
The default test command is "{{.FullCmd}} --versioncmd".