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
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