2 ms·
So will 'defer', and that is much more idiomatic and well-understood in the Go community.
by yawaramin 3y ago
So will 'defer', and that is much more idiomatic and well-understood in the Go community.
- cratermoon 3y agoGranted, but that only works for a subset of all cases. Remember that FDs can also refer to sockets and other things that aren't "files". A careful programmer will ensure that all FDs get cleaned up, but even careful programmers can fall victim to corner cases.
- yawaramin 3y agoI don't see why 'defer' wouldn't work for FDs or any other resource. There's nothing about 'defer' that says it will work only with 'files'. In fact I've been using it for general-purpose resource management for a while now.