Skip to content

Commit

Permalink
util: fix calls to crash with t
Browse files Browse the repository at this point in the history
  • Loading branch information
shoenig committed Aug 27, 2024
1 parent e733f53 commit d605eb2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions util/tempfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ func TempFile(t T, settings ...TempFileSetting) (path string) {
}

var err error
crash := func(t T)
crash := func(t T) {
t.Helper()
t.Fatalf("%s: %v", "TempFile", err)
}
file, err := os.CreateTemp(*allSettings.path, allSettings.namePattern)
if err != nil {
crash()
crash(t)
}
path = file.Name()
t.Cleanup(func() {
Expand All @@ -104,15 +104,15 @@ func TempFile(t T, settings ...TempFileSetting) (path string) {
_, err = file.Write(allSettings.data)
if err != nil {
file.Close()
crash()
crash(t)
}
err = file.Close()
if err != nil {
crash()
crash(t)
}
err = os.Chmod(path, *allSettings.mode)
if err != nil {
crash()
crash(t)
}
return file.Name()
}

0 comments on commit d605eb2

Please sign in to comment.