Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
Log = log.Info
)
Log is a convenience alias for log.Info, intended for use within task Run functions to output informational messages during task execution.
Example:
Run: func() {
Log("Building version %s", version)
Run(`go build ./...`)
}
Functions ¶
func Deps ¶ added in v0.1.0
Deps is a convenience function for creating string slices for Task.Dependencies. It provides clearer intent than using []string{} directly and makes task definitions more readable.
Example:
Task{
Name: "test",
Dependencies: Deps("build", "lint"),
}
func Makefile ¶
func Makefile(tasks ...Task)
Makefile is the main entry point for go-make. It registers all provided tasks, adds built-in tasks (help, clean, binny:*, etc.), sets up signal handling, and executes the requested task(s) from command-line arguments.
Makefile handles:
- Signal handling for graceful shutdown (SIGINT, SIGTERM)
- Periodic stack traces in debug mode for diagnosing hangs
- Automatic cleanup via config.DoExit() on completion
- Panic recovery with formatted error output
If no task is specified on the command line, "help" is run by default.
Example:
func main() {
Makefile(
golint.Tasks(),
gotest.Tasks(),
Task{Name: "build", Run: func() { Run(`go build ./...`) }},
)
}
func RootDir ¶ added in v0.1.0
func RootDir() string
RootDir returns the root directory of the repository; typically the repository root, located by the .git directory
func Run ¶
Run executes a shell command with automatic template rendering and binny tool management.
The command string is first parsed using shell.Split to handle quoted arguments properly, then all parts are rendered through the template engine to expand variables like {{RootDir}}. If the command references a binny-managed tool (configured in .binny.yaml), that tool will be automatically installed if not already present.
By default, Run panics on command failure. Use run.NoFail() to return an empty string instead of panicking. Returns stdout as a trimmed string.
Example:
Run(`go build -o {{ToolDir}}/myapp ./cmd/myapp`)
Run(`golangci-lint run`, run.Quiet())
version := Run(`git describe --tags`, run.NoFail())
Types ¶
type Task ¶
type Task struct {
// Name is the unique identifier for this task. Used for:
// - Running directly: `make taskname`
// - Specifying in Dependencies: Deps("taskname")
// - Referencing in RunsOn labels
Name string
// Aliases are additional names that resolve to this task, e.g. for keeping a
// legacy name working after a rename. `make <alias>` runs this task. Aliases
// are not shown in help.
//
// Example: Name: "lint:fix", Aliases: List("lint-fix")
Aliases []string
// Description is shown in help output. Keep it brief and action-oriented.
Description string
// Dependencies lists tasks that must complete successfully before this task runs.
// These tasks are "pulled in" as prerequisites. Use Deps() helper for cleaner syntax.
//
// Example: Dependencies: Deps("build", "lint")
Dependencies []string
// RunsOn lists label names that will trigger this task. When any task in this list runs,
// this task will also run. This is the inverse of Dependencies - it "hooks" this task
// to run as part of another task.
//
// Common labels include "test", "clean", "default", and "dependencies:update".
//
// Example: RunsOn: List("test") causes this task to run whenever "make test" is called.
RunsOn []string
// Tasks defines nested subtasks. Subtask names are automatically prefixed with the parent
// name using ":" as separator. For example, a subtask named "snapshot" under a parent
// named "release" becomes "release:snapshot".
//
// Subtasks can still hook into other tasks via RunsOn without the prefix.
Tasks []Task
// Run is the function that implements this task's behavior. If nil, the task acts as
// a label/phase that other tasks can depend on or hook into.
Run func()
}
Task defines a unit of work in the build system. Tasks can have dependencies, respond to labels, contain subtasks, and execute arbitrary Go code.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal/cmd/gen-github-ssh-keys
command
|
|
|
internal
|
|
|
redact
Package redact masks credential-bearing values so they don't reach logs, error messages, or anywhere else go-make prints.
|
Package redact masks credential-bearing values so they don't reach logs, error messages, or anywhere else go-make prints. |
|
tasks
|
|