Skip to content

Commit

Permalink
fix issue of space char in binary pth of gofmt/goimports
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed May 19, 2022
1 parent 350ee9f commit d7c5a08
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/gf/internal/utility/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ var (
goimportsPath = gproc.SearchBinaryPath("goimports") // gofmtPath is the binary path of command `goimports`.
)

func init() {
// Wraps the command binary path with char '"' if there's space char in the path.
if gstr.Contains(gofmtPath, " ") {
gofmtPath = fmt.Sprintf(`"%s"`, gofmtPath)
}
if gstr.Contains(goimportsPath, " ") {
goimportsPath = fmt.Sprintf(`"%s"`, goimportsPath)
}
}

// GoFmt formats the source file using command `gofmt -w -s PATH`.
func GoFmt(path string) {
if gofmtPath == "" {
Expand Down

0 comments on commit d7c5a08

Please sign in to comment.