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 5
5
package config
6
6
7
7
import (
8
+ "bytes"
8
9
"flag"
9
10
"fmt"
10
11
"io/ioutil"
11
12
"os"
13
+ "os/exec"
12
14
13
15
"github.com/gin-gonic/gin"
14
16
"github.com/sirupsen/logrus"
@@ -57,9 +59,21 @@ Usage:
57
59
if err != nil {
58
60
logrus .Fatalf ("fatal: fail to parse configuration file: %v" , err )
59
61
}
62
+ commandCheck ()
60
63
gin .SetMode (conf .Mode )
61
64
62
65
logrus .SetFormatter (& logrus.TextFormatter {})
63
66
logrus .SetReportCaller (false )
64
67
logrus .Infof ("load config file: %q" , f )
65
68
}
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