Skip to content

Commit

Permalink
feat: write code into file for debugging in case of goimports failure…
Browse files Browse the repository at this point in the history
…s instead of printing the full buffer into the terminal
  • Loading branch information
dreadl0ck committed Nov 15, 2021
1 parent bf8ff03 commit 6d866b9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,16 @@ func Build(conf *config.Config, goPath string) {
os.Stderr,
" goimports does not like the generated code: ",
errProcessImports,
", this is the code: ",
code,
)

// write code into file for debugging
writeErr := ioutil.WriteFile(filename, []byte(code), 0644)
if writeErr != nil {
fmt.Fprintln(os.Stderr, " could not write go source to file", writeErr)
os.Exit(5)
}
fmt.Fprintln(os.Stderr, "wrote code for debugging into file", filename)

os.Exit(5)
}

Expand Down

0 comments on commit 6d866b9

Please sign in to comment.