Skip to content

Commit 3e57a4b

Browse files
committed
Fix run goimports with go tool
1 parent 6bc4c37 commit 3e57a4b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

main.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,15 @@ func main() {
7777
}
7878

7979
if *op != "" {
80-
cmd := "goimports"
80+
var cmd *exec.Cmd
8181
if *useGoTool {
82-
cmd = "go tool goimports"
82+
params := []string{"tool", "goimports", "-w", *op}
83+
cmd = exec.Command("go", params...)
84+
} else {
85+
params := []string{"-w", *op}
86+
cmd = exec.Command("goimports", params...)
8387
}
84-
params := []string{"-w", *op}
85-
if err := exec.Command(cmd, params...).Run(); err != nil {
88+
if err := cmd.Run(); err != nil {
8689
app.Errorf("failed to goimports: %s", err)
8790
}
8891
}

0 commit comments

Comments
 (0)