Replace a project's Makefile with Go functions that work consistently on Windows, macOS, and Linux.
Define build targets like test, build, and deploy in a Go file that any team member can run with a single mage command.
Write cross-platform build scripts that use Go's standard library for file operations and error handling instead of bash syntax.
Mage is a build automation tool for Go projects. If you have worked with Makefiles, the concept is similar: you define a set of named tasks, and a tool runs them for you. The difference is that with Mage, those tasks are written in plain Go functions rather than in a separate scripting language. The project lives at magefile.org, where the full documentation is hosted. The motivation for Mage comes from the awkwardness of Makefiles on real projects. Makefiles rely on bash-style syntax that is hard to read, does not behave consistently across operating systems, and is unfamiliar to developers whose main language is Go. Mage removes that friction by letting you write your build logic in the same language as the rest of your code, with access to Go's standard library and all its tools for looping, branching, and error handling. Installing Mage depends on which version of Go you are using. With Go 1.18 or newer, a single go install command fetches and builds it. Older versions can use go get followed by a bootstrap script. You can also download a prebuilt binary from the project's releases page. Mage has no external dependencies beyond the Go standard library itself, and it works on Windows, macOS, and Linux. Once installed, you create one or more magefiles containing ordinary Go functions. Mage reads those files and exposes each exported function as a runnable target. You can name the files whatever you like, and you can maintain separate ones for different purposes. The tool is discussed in a community Slack channel and a Google Group where users share usage patterns and report issues.
← magefile on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.