To me, stream.autoClose()
sounds like I’m closing immediately. To assume otherwise requires additional knowlege or surrounding scope (using
).
Go language has defer
statement which has the effect of executing given function after the surrounding function returns. It is used like this:
f, err := os.Open(name)
defer f.Close()
Maybe the better name for autoClose
is deferClose
.