Skip to content

Commit

Permalink
Make sure that the buffer is written to the file
Browse files Browse the repository at this point in the history
  • Loading branch information
majori committed Nov 9, 2023
1 parent 7116bc2 commit 8c1a8b2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/action/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func main() {

output, err := os.OpenFile(filename, os.O_APPEND, 0644)
checkErr(err)
defer output.Close()

cmd := cli.NewRootCmd(version)
err = cmd.ExecuteContext(context.Background())
Expand All @@ -41,6 +40,10 @@ func main() {
}
fmt.Fprintf(output, "exit-code=%d\n", exitCode)

// Write buffer to the file
output.Sync()

Check failure on line 44 in cmd/action/main.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `output.Sync` is not checked (errcheck)

Check failure on line 44 in cmd/action/main.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `output.Sync` is not checked (errcheck)
output.Close()

// Map all non error exit codes to 0 so that Github Actions job does not fail
if exitCode != cli.ExitCodeError {
os.Exit(cli.ExitCodeOK)
Expand Down

0 comments on commit 8c1a8b2

Please sign in to comment.