From d4b620c94f13d10cb7ccc463627c4ed7765120c1 Mon Sep 17 00:00:00 2001 From: Shaunn Barron Date: Tue, 20 Mar 2018 11:27:29 -0400 Subject: [PATCH] Check for dep and goimports before go getting. (#977) --- generators/newapp/new.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/generators/newapp/new.go b/generators/newapp/new.go index 18a6f908d..b21974549 100644 --- a/generators/newapp/new.go +++ b/generators/newapp/new.go @@ -32,9 +32,14 @@ func (a Generator) Run(root string, data makr.Data) error { os.RemoveAll(a.Root) } - g.Add(makr.NewCommand(makr.GoGet("golang.org/x/tools/cmd/goimports", "-u"))) + if _, err := exec.LookPath("goimports"); err != nil { + g.Add(makr.NewCommand(makr.GoGet("golang.org/x/tools/cmd/goimports", "-u"))) + } + if a.WithDep { - g.Add(makr.NewCommand(makr.GoGet("github.com/golang/dep/cmd/dep", "-u"))) + if _, err := exec.LookPath("dep"); err != nil { + g.Add(makr.NewCommand(makr.GoGet("github.com/golang/dep/cmd/dep", "-u"))) + } } files, err := generators.FindByBox(packr.NewBox("../newapp/templates"))