Commit 6cbd737c authored by Ian Lance Taylor's avatar Ian Lance Taylor

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/+/202137Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 04e80fb2
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
// if err != nil { // if err != nil {
// log.Fatal("could not create CPU profile: ", err) // 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 { // if err := pprof.StartCPUProfile(f); err != nil {
// log.Fatal("could not start CPU profile: ", err) // log.Fatal("could not start CPU profile: ", err)
// } // }
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
// if err != nil { // if err != nil {
// log.Fatal("could not create memory profile: ", err) // 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 // runtime.GC() // get up-to-date statistics
// if err := pprof.WriteHeapProfile(f); err != nil { // if err := pprof.WriteHeapProfile(f); err != nil {
// log.Fatal("could not write memory profile: ", err) // log.Fatal("could not write memory profile: ", err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment