[go-nuts] Re: Error when using go tool trace

2017-08-03 Thread evan . explodes
I ran into this same problem, and found this post! It looks like you're making the same simple mistake I was: # erroneous: defer f.Close() defer trace.Stop() You must stop the trace *before* closing the output file. # corrected: defer func() { trace.Stop() panic(f.Close()) # Be sure to handl

[go-nuts] Re: Error when using go tool trace

2017-08-04 Thread evan . explodes
Ah, excellent. Good catch. I learned something about defer. The ordering of the close was my problem, however. The way I *actually* handle closing the trace is: func (t *FileTracer) Stop() error { if t == nil { return nil } trace.Stop() return t.f.Close() } On Friday, August 4, 2017 at 12:42:31