A Go-native build orchestrator, type-safe and dependency-free.
Why GOBAKE?
A Programmer's Best Friend
Go-Native
Native Execution. Fast and elegant.
Go-Native changed how we build. It's the most natural build tool I've ever experienced.
Fezcode
CREATOR
Zero Dependencies
Pure Go. No external mess.
Zero Dependencies means no more dependency hell. It's a breath of fresh air for our CI/CD.
Metadata Management
Centralized control. Single Source.
Metadata Management brings sanity to our versioning. Absolute game changer for release engineering.
Self-Bootstrapping
Autonomous builds. Self-healing.
Self-Bootstrapping is magic. It handles its own lifecycle perfectly so I don't have to.
DOCUMENTATION
Core Concepts
gobake operates on a simple principle: Your build system should be as robust as your application.
Instead of relying on fragile shell scripts or complex Makefiles, gobake uses:
- Engine: The core Go library that manages tasks and metadata.
- Context: A helper object passed to every task, providing access to the shell, logging, and environment.
- Recipe: The
Recipe.gofile (using//go:build gobake) that ties it all together.
CLI Command Reference
Project Management
gobake init: Initialize a new project in the current directory. Automatesgo modand dependency setup.gobake version: Show the current version of gobake.gobake help: Show the list of available commands and project tasks.gobake template <git-url>: Clone a repository and initialize it as a gobake project.
Dependency & Tool Management
gobake add-tool <url>: Adds a tool to the(tools)list inrecipe.piml.gobake remove-tool <url>: Removes a tool fromrecipe.piml.gobake add-dep <url>: Adds a library dependency usinggo get.gobake remove-dep <url>: Removes a library dependency.
Versioning
gobake bump [patch|minor|major]: Increments the project version inrecipe.piml.
Metadata (recipe.piml)
The recipe.piml file is the single source of truth for your project.
(name) my-project
(version) 1.2.3
(authors)
> Fezcode
(tools)
> github.com/swaggo/swag/cmd/swag@latest
Task Management
Tasks are defined in the Run(*gobake.Engine) function using bake.Task(name, description, function).
Task Dependencies
You can define tasks that depend on other tasks using bake.TaskWithDeps.
bake.Task("test", "Run tests", func(ctx *gobake.Context) error { ... })
bake.TaskWithDeps("build", "Build app", []string{"test"}, func(ctx *gobake.Context) error { ... })
Cross-Compilation
Use ctx.BakeBinary(os, arch, output, flags...) for simple cross-compilation tasks.
bake.Task("release", "Cross-compile", func(ctx *gobake.Context) error {
return ctx.BakeBinary("linux", "amd64", "bin/app")
})
gobake Examples
1. Cross-Compilation for Multiple Platforms
This recipe builds your application for Windows, Linux, and macOS.
//go:build gobake
package bake_recipe
import (
"fmt"
"github.com/fezcode/gobake"
)
func Run(bake *gobake.Engine) error {
if err := bake.LoadRecipeInfo("recipe.piml"); err != nil {
return err
}
bake.Task("release", "Build for all platforms", func(ctx *gobake.Context) error {
platforms := []struct {
OS string
Arch string
Ext string
}{
{"linux", "amd64", ""},
{"windows", "amd64", ".exe"},
{"darwin", "arm64", ""},
}
for _, p := range platforms {
output := fmt.Sprintf("dist/%s-%s-%s%s",
bake.Info.Name, p.OS, p.Arch, p.Ext)
err := ctx.BakeBinary(p.OS, p.Arch, output, "-ldflags", "-s -w")
if err != nil {
return err
}
}
return nil
})
return nil
}
2. Using External Tools
This recipe installs stringer and uses it to generate code before building.
recipe.piml:
(name) my-app
(tools)
> golang.org/x/tools/cmd/stringer@latest
Recipe.go:
//go:build gobake
package bake_recipe
import (
"fmt"
"github.com/fezcode/gobake"
)
func Run(bake *gobake.Engine) error {
if err := bake.LoadRecipeInfo("recipe.piml"); err != nil {
return fmt.Errorf("error loading recipe.piml: %v", err)
}
bake.Task("generate", "Generates code", func(ctx *gobake.Context) error {
// Ensure tools are installed first
if err := ctx.InstallTools(); err != nil {
return err
}
ctx.Log("Running stringer...")
return ctx.Run("go", "generate", "./...")
})
bake.TaskWithDeps("build", "Builds app", []string{"generate"}, func(ctx *gobake.Context) error {
return ctx.Run("go", "build", ".")
})
return nil
}
3. Injecting Version with ldflags
Inject project version from recipe.piml into your binary.
Recipe.go:
//go:build gobake
package bake_recipe
import (
"fmt"
"github.com/fezcode/gobake"
)
func Run(bake *gobake.Engine) error {
if err := bake.LoadRecipeInfo("recipe.piml"); err != nil {
return err
}
bake.Task("build", "Build with version", func(ctx *gobake.Context) error {
ldflags := fmt.Sprintf("-X main.Version=%s", bake.Info.Version)
ctx.Log("Building version %s...", bake.Info.Version)
return ctx.Run("go", "build", "-ldflags", ldflags, "-o", "bin/app")
})
return nil
}
GUIDE NAV
READY TO GOBAKE?
go install github.com/fezcode/gobake/cmd/gobake@latest