Add fmt check command
This commit is contained in:
parent
db03a45165
commit
6ec1ce9730
16
magefile.go
16
magefile.go
|
@ -216,8 +216,22 @@ func Fmt() {
|
|||
}
|
||||
|
||||
// Checks if the code is properly formatted with go fmt
|
||||
func FmtCheck() {
|
||||
func FmtCheck() error {
|
||||
args := append([]string{"-s", "-d"}, GoFiles...)
|
||||
c := exec.Command("gofmt", args...)
|
||||
out, err := c.Output()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(out) > 0 {
|
||||
fmt.Println("Code is not properly gofmt'ed.")
|
||||
fmt.Println("Please run 'mage fmt' and commit the result:")
|
||||
fmt.Print(string(out))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Lint() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user