File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 55package config
66
77import (
8+ "bytes"
89 "flag"
910 "fmt"
1011 "io/ioutil"
1112 "os"
13+ "os/exec"
1214
1315 "github.com/gin-gonic/gin"
1416 "github.com/sirupsen/logrus"
@@ -57,9 +59,21 @@ Usage:
5759 if err != nil {
5860 logrus .Fatalf ("fatal: fail to parse configuration file: %v" , err )
5961 }
62+ commandCheck ()
6063 gin .SetMode (conf .Mode )
6164
6265 logrus .SetFormatter (& logrus.TextFormatter {})
6366 logrus .SetReportCaller (false )
6467 logrus .Infof ("load config file: %q" , f )
6568}
69+
70+ func commandCheck () {
71+ // check goimports
72+ cmd := exec .Command ("goimports" , "-h" )
73+ cmd .Stderr = & bytes.Buffer {}
74+ err := cmd .Run ()
75+ if err != nil && cmd .Stderr .(* bytes.Buffer ).String () == "" {
76+ logrus .Fatalf ("fatal: goimports commond not found: %v" , err )
77+ return
78+ }
79+ }
You can’t perform that action at this time.
0 commit comments