Documentation ¶
Index ¶
- Variables
- func All[T any](values ...T) []T
- func AllNotNil[T any](values ...T) []T
- func BinnyInstall(cmd string) string
- func BuildFromGoSource(file string, module, entrypoint, version string, opts ...ExecOpt)
- func Cancel()
- func Catch(fn func()) (err error)
- func Cd(dir string)
- func Close(closeable io.Closer)
- func Cwd() string
- func DebugLog(format string, args ...any)
- func DelimiterSplitFlat(delimiterSeparatedString, delimiter string) []string
- func EnsureFileExists(file string)
- func Exec(cmd string, opts ...ExecOpt) error
- func Fetch(urlString string, options ...FetchOption) (contents []byte, statusCode int, statusLine string)
- func FileContains(file, substr string) bool
- func FileExists(file string) bool
- func FindFile(glob string) string
- func FindFiles(glob string) []string
- func FingerprintFiles(files ...string) string
- func FingerprintGlobs(globs ...string) string
- func Get[T any](t T, e error) T
- func GitRevision() string
- func GitRoot() string
- func GoDepVersion(module string) string
- func HandleErrors()
- func InDir(dir string, run func())
- func InGitClone(repo, branch string, fn func())
- func InTempDir(fn func())
- func IsBinnyManagedTool(cmd string) bool
- func IsDir(dir string) bool
- func IsRegularFile(name string) bool
- func LogErr(err error)
- func Makefile(tasks ...Task)
- func NoErr(e error)
- func PathJoin(paths ...string) string
- func ReadFile(file string) string
- func ReadGoMod() *modfile.File
- func RepoRoot() string
- func Rmdir(dir string)
- func Run(cmd ...string)
- func RunBinny()
- func RunE(cmd ...string) (string, string, error)
- func RunGoTask()
- func RunTools()
- func RunWithOptions(cmd string, opts ...ExecOpt)
- func ShellSplit(s string) []string
- func SplitFlat(commaSeparatedString string) []string
- func Throw(err error)
- func ToolPath(toolName string) string
- func Tpl(template string, args ...map[string]any) string
- func WithTempDir(fn func(dir string))
- func WriteFile(path, contents string)
- type Context
- type ExecOpt
- func ExecArgs(args ...string) ExecOpt
- func ExecEnv(key, val string) ExecOpt
- func ExecErrToFile(path string) ExecOpt
- func ExecOpts(opts ...ExecOpt) ExecOpt
- func ExecOut(stdout io.Writer, stderr ...io.Writer) ExecOpt
- func ExecOutToFile(path string) ExecOpt
- func ExecStd() ExecOpt
- func Ldflags(flags ...string) ExecOpt
- type FetchOption
- type OkError
- type StackTraceError
- type Task
- type ToolContext
Constants ¶
This section is empty.
Variables ¶
var ( ToolDir = "{{RootDir}}/.tool" Platform = "{{OS}}/{{Arch}}" OS = runtime.GOOS Arch = runtime.GOARCH )
var Debug = func(format string, args ...any) {}
var Globals = Context{}
var Log = func(format string, args ...any) { _, _ = fmt.Fprintf(os.Stderr, LogPrefix+Tpl(format)+NewLine, args...) }
var LogPrefix = ""
var NewLine = fmt.Sprintln()
var RootDir = func() string { return Tpl("{{RepoRoot}}") }
RootDir is a function to return the root directory which builds run from
var TmpDirRoot = ""
TmpDirRoot is a directory to use as the base for temporary directories, defaults to system temp dir if empty
Functions ¶
func BinnyInstall ¶
BinnyInstall installs the named executable and returns an absolute path to it
func BuildFromGoSource ¶
func Catch ¶
func Catch(fn func()) (err error)
Catch handles panic values and returns any error caught
func Cd ¶
func Cd(dir string)
Cd changes the current working directory to the provided relative or absolute directory
func DelimiterSplitFlat ¶
func EnsureFileExists ¶
func EnsureFileExists(file string)
EnsureFileExists halts execution if the provided file does not exist
func Fetch ¶
func Fetch(urlString string, options ...FetchOption) (contents []byte, statusCode int, statusLine string)
func FileContains ¶
FileContains indicates the given file contains the provided substring
func FileExists ¶
FileExists indicates a file of any type (regular, directory, symlink, etc.) exists and is readable
func FingerprintFiles ¶
FingerprintFiles hashes all files and provides a stable hash of all the contents
func FingerprintGlobs ¶
FingerprintGlobs fingerprints all files matching the provided glob expression, providing a stable hash of all contents
func GitRevision ¶
func GitRevision() string
func GoDepVersion ¶
GoDepVersion returns the version found for the requested dependency in the first go.mod file found
func HandleErrors ¶
func HandleErrors()
HandleErrors is a utility to make errors and error codes handled prettier
func InDir ¶
func InDir(dir string, run func())
InDir executes the given function in the provided directory, returning to the current working directory upon completion
func InGitClone ¶
func InGitClone(repo, branch string, fn func())
func InTempDir ¶
func InTempDir(fn func())
InTempDir executes with current working directory in a new temporary directory, restoring cwd and removing all contents of the temp directory upon completion
func IsBinnyManagedTool ¶
func IsRegularFile ¶
IsRegularFile indicates the provided file exists and is a regular file, not a directory or symlink
func Rmdir ¶
func Rmdir(dir string)
Rmdir removes the given directory, first verifying it is a subdirectory of RootDir
func RunWithOptions ¶
func ShellSplit ¶
ShellSplit splits a string at spaces, taking into account shell quotes and {{template directives}}
func WithTempDir ¶
func WithTempDir(fn func(dir string))
WithTempDir creates a temporary directory, provided for the duration of the function call, removing all contents upon completion
Types ¶
type ExecOpt ¶
ExecOpt is used to alter the command used in Exec calls
func ExecErrToFile ¶
func ExecOutToFile ¶
type FetchOption ¶
func FetchHeaders ¶
func FetchHeaders(headers map[string]string) FetchOption
type StackTraceError ¶
StackTraceError provides nicer stack information
func (*StackTraceError) Error ¶
func (s *StackTraceError) Error() string