]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/pprof: update example comment to check error on Close
authorIan Lance Taylor <iant@golang.org>
Sat, 19 Oct 2019 06:16:16 +0000 (23:16 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 5 Nov 2019 00:19:10 +0000 (00:19 +0000)
Programs should always check the error return of Close for a file opened
for writing. Update the example code in the comment to mention this.

Change-Id: I2ff6866ff1fe23b47c54268ac8e182210cc876c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/202137
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/runtime/pprof/pprof.go

index 74cdd15cfbd16b47340df786e39d17d25d72fb8b..2fc567ef3416d1f5e550e9399c44cc6f1241dc0b 100644 (file)
@@ -28,7 +28,7 @@
 //            if err != nil {
 //                log.Fatal("could not create CPU profile: ", err)
 //            }
-//            defer f.Close()
+//            defer f.Close() // error handling omitted for example
 //            if err := pprof.StartCPUProfile(f); err != nil {
 //                log.Fatal("could not start CPU profile: ", err)
 //            }
@@ -42,7 +42,7 @@
 //            if err != nil {
 //                log.Fatal("could not create memory profile: ", err)
 //            }
-//            defer f.Close()
+//            defer f.Close() // error handling omitted for example
 //            runtime.GC() // get up-to-date statistics
 //            if err := pprof.WriteHeapProfile(f); err != nil {
 //                log.Fatal("could not write memory profile: ", err)