aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2019-10-18 23:16:16 -0700
committerIan Lance Taylor <iant@golang.org>2019-11-05 00:19:10 +0000
commit6cbd737c8e4a5aa5a8e85895c5ee6ff53a358622 (patch)
tree5de01b3839066b2623a2a87594e2e2699b9b0c41 /src/runtime
parent04e80fb2c9e502c011d367ad36307290df07cb41 (diff)
downloadgo-6cbd737c8e4a5aa5a8e85895c5ee6ff53a358622.tar.xz
runtime/pprof: update example comment to check error on Close
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>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/pprof/pprof.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go
index 74cdd15cfb..2fc567ef34 100644
--- a/src/runtime/pprof/pprof.go
+++ b/src/runtime/pprof/pprof.go
@@ -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)