Skip to content

Commit 9f92e06

Browse files
committed
Clean up the defer example a bit
1 parent 2a6ddb9 commit 9f92e06

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

examples/defer/defer.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ func createFile(p string) *os.File {
3737
func writeFile(f *os.File) {
3838
fmt.Println("writing")
3939
fmt.Fprintln(f, "data")
40-
4140
}
4241

4342
func closeFile(f *os.File) {
@@ -46,7 +45,6 @@ func closeFile(f *os.File) {
4645
// It's important to check for errors when closing a
4746
// file, even in a deferred function.
4847
if err != nil {
49-
fmt.Fprintf(os.Stderr, "error: %v\n", err)
50-
os.Exit(1)
48+
panic(err)
5149
}
5250
}

examples/defer/defer.hash

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
f0eb978a0cdbacc5e4d709bccce6cea6b71be39f
2-
5SDVfc_jxbg
1+
249d0bc915e075a664be8b4e9115aa9568c8999e
2+
nhAzhDn_jga

public/defer

+5-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)