Convert Figma logo to code with AI

magefile logomage

a Make/rake-like dev tool using Go

4,104
251
4,104
122

Top Related Projects

10,982

A task runner / simpler Make alternative written in Go

Quick Overview

Mage is a Make-like build tool using Go. It provides a simple and flexible way to define and run build tasks, without the complexity of a traditional Makefile. Mage aims to be a more modern and Go-centric alternative to tools like Make, Rake, or Gulp.

Pros

  • Simple and Flexible: Mage allows you to define build tasks using Go functions, making it easy to leverage the full power of the Go language.
  • Cross-Platform: Mage is a single, cross-platform binary that can be used on Windows, macOS, and Linux.
  • Dependency Management: Mage automatically handles dependencies between tasks, ensuring that tasks are only run when necessary.
  • Powerful Scripting: Mage's Go-based approach allows for more advanced scripting capabilities compared to traditional build tools.

Cons

  • Learning Curve: Developers who are familiar with traditional build tools like Make may need to invest time in learning Mage's syntax and approach.
  • Vendor Lock-in: Mage is a Go-specific tool, which may limit its adoption in projects that use other programming languages.
  • Overhead: The need to compile Mage into a binary may add some overhead compared to tools like Make, which are typically just shell scripts.
  • Ecosystem: Mage has a smaller ecosystem compared to more established build tools, which may limit the availability of pre-built tasks or plugins.

Getting Started

To get started with Mage, follow these steps:

  1. Install Mage by running the following command:
go install github.com/magefile/mage@latest
  1. Create a new file named magefile.go in your project's root directory, and define your build tasks using Go functions. Here's an example:
// +build mage

package main

import (
    "fmt"
    "os"
)

// Build the project.
func Build() error {
    fmt.Println("Building the project...")
    // Add your build logic here
    return nil
}

// Clean up the build artifacts.
func Clean() {
    fmt.Println("Cleaning up the build artifacts...")
    os.RemoveAll("build")
}

// Test the project.
func Test() error {
    fmt.Println("Running tests...")
    // Add your test logic here
    return nil
}
  1. Run Mage commands to execute your build tasks:
mage build  # Runs the Build() function
mage clean  # Runs the Clean() function
mage test   # Runs the Test() function

That's the basic setup to get started with Mage. You can further customize your build tasks and leverage Mage's advanced features, such as dependency management and parallel task execution, as your project grows in complexity.

Competitor Comparisons

10,982

A task runner / simpler Make alternative written in Go

Pros of go-task/task

  • Simplicity: go-task/task has a simpler and more straightforward syntax compared to magefile/mage, making it easier to learn and use.
  • Cross-platform: go-task/task is designed to be cross-platform, supporting Windows, macOS, and Linux, while magefile/mage is primarily focused on the Go ecosystem.
  • Dependency Management: go-task/task provides built-in support for managing dependencies, which can be useful for complex projects.

Cons of go-task/task

  • Limited Functionality: go-task/task may have fewer features and customization options compared to magefile/mage, which is more focused on the Go ecosystem.
  • Slower Execution: go-task/task may have slower execution times compared to magefile/mage, as it is a separate binary that needs to be executed.
  • Lack of Integration: go-task/task may have less integration with the Go toolchain and ecosystem compared to magefile/mage.

Code Comparison

magefile/mage:

func Build() {
    mg.Deps(Generate)
    fmt.Println("Building the project...")
    // build the project
}

func Generate() {
    fmt.Println("Generating code...")
    // generate code
}

go-task/task:

build:
  cmds:
    - echo "Building the project..."
    - # build the project

generate:
  cmds:
    - echo "Generating code..."
    - # generate code

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Built with Mage Build Status Build status

About

Mage is a make-like build tool using Go. You write plain-old go functions, and Mage automatically uses them as Makefile-like runnable targets.

Installation

Mage has no dependencies outside the Go standard library, and builds with Go 1.7 and above (possibly even lower versions, but they're not regularly tested).

Using GOPATH

go get -u -d github.com/magefile/mage
cd $GOPATH/src/github.com/magefile/mage
go run bootstrap.go

Using Go Modules

git clone https://github.com/magefile/mage
cd mage
go run bootstrap.go

This will download the code and then run the bootstrap script to build mage with version infomation embedded in it. A normal go get (without -d) or go install will build the binary correctly, but no version info will be embedded. If you've done this, no worries, just go to $GOPATH/src/github.com/magefile/mage and run mage install or go run bootstrap.go and a new binary will be created with the correct version information.

The mage binary will be created in your $GOPATH/bin directory.

You may also install a binary release from our releases page.

Demo

Mage Demo

Discussion

Join the #mage channel on gophers slack or post on the magefile google group for discussion of usage, development, etc.

Documentation

See magefile.org for full documentation.

See pkg.go.dev/github.com/magefile/mage/mage for instructions on how to use Mage as a library.

Why?

Makefiles are hard to read and hard to write. Mostly because makefiles are essentially fancy bash scripts with significant white space and additional make-related syntax.

Mage lets you have multiple magefiles, name your magefiles whatever you want, and they're easy to customize for multiple operating systems. Mage has no dependencies (aside from go) and runs just fine on all major operating systems, whereas make generally uses bash which is not well supported on Windows. Go is superior to bash for any non-trivial task involving branching, looping, anything that's not just straight line execution of commands. And if your project is written in Go, why introduce another language as idiosyncratic as bash? Why not use the language your contributors are already comfortable with?

Thanks

If you use mage and like it, or any of my other software, and you'd like to show your appreciation, you can do so on my patreon:

<img src=https://user-images.githubusercontent.com/3185864/49846051-64eddf80-fd97-11e8-9f59-d09f5652d214.png>