Correct Error Handling is Hard
Peter Goetz
674

This will race in parallel execution. Idiomatic Go way would be to use sync.Once to make sure you always call Close() once:

type SafeCloser struct {}

func (safeCloser *SafeCloser) Close(closer io.Closer) (err error) {

once.Do(func() {
err = closer.Close()
})

return
}
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.