Mage 类似make&&rake 基于golang 的build 工具

Mage 是基于golang 开发的,类似make/rake 的工具,我们可以使用golang 代码编写类似make 的功能
以下是一个简单的使用

安装

 
go get -u -d github.com/magefile/mage

基本使用

  • 代码
go mod init github.com/rongfengliang/build-make
main.go
//+build mage
package main
import (
    "fmt"
    "github.com/magefile/mage/sh"
)
// echo && ls
func Build() {
    if err := sh.Run("ls", "-sialh", "."); err != nil {
        fmt.Println("some wrong")
    }
    sh.RunV("echo", "$PWD")
}

说明

类似的工具还是很多的,比如go-task,just,tusk

参考资料

https://github.com/magefile/mage
https://github.com/casey/just
https://github.com/rliebz/tusk
https://github.com/go-task/task

原文地址:https://www.cnblogs.com/rongfengliang/p/13245742.html