Closed dmitshur closed 1 year ago
Thanks.
I don't know how StartCPUProfile can error, but I suppose it can. Learn something every day.
Me too, learned from looking at the example at https://pkg.go.dev/runtime/pprof#hdr-Profiling_a_Go_program. Its docs say "StartCPUProfile returns an error if profiling is already enabled." and today's implementation indeed seems to only do that.
Balance out
f.Create
with anf.Close
.Also bail out if
StartCPUProfile
returns a non-nil
error while here.I'm not sure if this matters or is helpful, but figured I'd ask by sending this PR. (Issue golang/go#26970 suggests there may be some benefit.)