Esempio n. 1
0
func (lt *goLintTask) Run(info *goauto.TaskInfo) (err error) {
	t0 := time.Now()
	info.Target = info.Src
	info.Buf.Reset()
	dir := goauto.GoRelSrcDir(info.Src)
	targs := append(lt.args, dir)
	cmd := exec.Command("golint", 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 Lint %v %v\n", dir, t1.Sub(t0))
		}
	}()
	if err = cmd.Run(); err != nil {
		return
	}
	if info.Buf.Len() > 0 {
		err = errors.New("FAIL")
		return
	}
	return
}
Esempio n. 2
0
func (gt *goPrjTask) Run(info *goauto.TaskInfo) (err error) {
	t0 := time.Now()
	info.Target = info.Src
	info.Buf.Reset()
	dir := goauto.GoRelSrcDir(info.Src)
	targs := append([]string{gt.gocmd}, gt.args...)
	targs = append(targs, dir)
	gocmd := exec.Command("go", targs...)
	gocmd.Stdout = &info.Buf
	gocmd.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 %v %v %v\n", strings.Title(gt.gocmd), dir, t1.Sub(t0))
		}
	}()
	return gocmd.Run()
}