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