Skip to content

Commit

Permalink
Added support for github.com/alecthomas/gometalinter tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
dshills committed Apr 7, 2015
1 parent 2787cc1 commit a000541
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -182,6 +182,7 @@ GoAuto includes a number of pre built tasks that can be used directly.
* NewGoBuildTask will run build for a project
* NewGoInstallTask will run install for a project
* NewGoLintTask will run golint for a project
* NewGoMetaLinter task for github.com/alecthomas/gometalinter

##### goauto/shelltask

Expand Down
39 changes: 39 additions & 0 deletions gotask/gotask.go
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"os/exec"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -100,3 +101,41 @@ func (lt *goLintTask) Run(info *goauto.TaskInfo) (err error) {
func NewGoLintTask(args ...string) goauto.Tasker {
return &goLintTask{args: args}
}

type goMetaLinterTask struct {
args []string
}

func (t *goMetaLinterTask) Run(info *goauto.TaskInfo) (err error) {
t0 := time.Now()
info.Target = info.Src
info.Buf.Reset()
dir := filepath.Dir(info.Src)
targs := append(t.args, dir)
cmd := exec.Command("gometalinter", targs...)
cmd.Stdout = &info.Buf
cmd.Stderr = info.Terr
defer func() {
fmt.Fprint(info.Tout, info.Buf.String())
if err == nil && info.Verbose {
t1 := time.Now()
fmt.Fprintf(info.Tout, ">>> Go Meta Linter %v %v\n", dir, t1.Sub(t0))
}
}()
if err = cmd.Run(); err != nil {
println()
return
}
if info.Buf.Len() > 0 {
err = errors.New("FAIL")
return
}
return
}

// NewGoMetaLinterTask returns a task that will run gometalinter for the project
// go get github.com/alecthomas/gometalinter
// "Concurrently run Go lint tools and normalise their output"
func NewGoMetaLinterTask(args ...string) goauto.Tasker {
return &goMetaLinterTask{args: args}
}

0 comments on commit a000541

Please sign in to comment.