Skip to content

Commit

Permalink
Bad call order on close and remove
Browse files Browse the repository at this point in the history
  • Loading branch information
metal3d committed Jun 22, 2023
1 parent d0c1470 commit d0469a4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ordering/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ func ReorderSource(opt ReorderConfig) (string, error) {
return string(content), errors.New("Failed to create temp file: " + err.Error())
}
defer func() {
os.Remove(tmpfile.Name()) // clean up
// close and remove the temporary file
tmpfile.Close()
os.Remove(tmpfile.Name())
}()

if _, err := tmpfile.Write([]byte(output)); err != nil {
Expand Down

0 comments on commit d0469a4

Please sign in to comment.