goyek (/ˈɡɔɪæk/ 🔊 listen) is a task automation library intended to be an alternative to Make, Mage, Task.
Please ⭐ Star
this repository if you find it valuable.
The primary properties of goyek are:
- Library, not an application, with API inspired by
testing
,cobra
,flag
,http
. - Cross-platform and shell independent.
- No binary installation needed.
- Easy to debug, like regular Go code.
- Tasks are defined similarly to
cobra
commands. - The task action looks like a Go test.
goyek.A
has similar methods totesting.T
. - Reuse any Go code and library e.g.
viper
. - Highly customizable.
- Zero third-party dependencies.
- Additional features in
goyek/x
.
For build automation, store your code in the build
directory.
The following example defines a simple hello
task that logs a message
and prints the Go version.
Create build/hello.go
:
package main
import (
"flag"
"github.com/goyek/goyek/v2"
"github.com/goyek/x/cmd"
)
var msg = flag.String("msg", "greeting message", "Hello world!")
var hello = goyek.Define(goyek.Task{
Name: "hello",
Usage: "demonstration",
Action: func(a *goyek.A) {
a.Log(*msg)
cmd.Exec(a, "go version")
},
})
Create build/main.go
:
package main
import (
"os"
"github.com/goyek/goyek/v2"
"github.com/goyek/x/boot"
)
func main() {
if err := os.Chdir(".."); err != nil {
panic(err)
}
goyek.SetDefault(hello)
boot.Main()
}
The packages from github.com/goyek/x
are used for convenience.
Run help:
cd build
go mod tidy
go run . -h
Expected output:
Usage of build: [flags] [--] [tasks]
Tasks:
hello demonstration
Flags:
-dry-run
print all tasks without executing actions
-long-run duration
print when a task takes longer (default 1m0s)
-msg string
Hello world! (default "greeting message")
-no-color
disable colorizing output
-no-deps
do not process dependencies
-skip comma-separated tasks
skip processing the comma-separated tasks
-v print all tasks as they are run
Run with verbose output:
go run . -v
Example output:
===== TASK hello
hello.go:16: greeting message
hello.go:17: Exec: go version
go version go1.24.0 linux/amd64
----- PASS: hello (0.12s)
ok 0.123s
Instead of running go run .
inside build
, you can use wrapper scripts:
Use goyek/template
when creating
a new repository. For existing repositories, simply copy the relevant files.
Learn more:
- 📺 5-minute video: Watch here (Slides)
- 📚 Package documentation
We welcome contributions! See CONTRIBUTING.md for details.
goyek is licensed under the terms of the MIT license.
Note: goyek was named taskflow before v0.3.0.