github.com/lenfree/buffalo@v0.7.3-0.20170207163156-891616ea4064/buffalo/cmd/generate/gofmt.go (about)

     1  package generate
     2  
     3  import (
     4  	"os/exec"
     5  
     6  	"github.com/markbates/gentronics"
     7  )
     8  
     9  // Fmt is command that will use `goimports` if available,
    10  // or fail back to `gofmt` otherwise.
    11  var Fmt *gentronics.Command
    12  
    13  func init() {
    14  	c := "gofmt"
    15  	_, err := exec.LookPath("goimports")
    16  	if err == nil {
    17  		c = "goimports"
    18  	}
    19  	Fmt = gentronics.NewCommand(exec.Command(c, "-w", "."))
    20  }