logoalt Hacker News

database64128last Wednesday at 7:15 AM1 replyview on HN

Just write `defer v.Close()`? In almost all cases, `close(2)` errors can be safely ignored. Rust also does this: https://github.com/rust-lang/rust/blob/792fc2b033aea7ea7b766...


Replies

catlifeonmarslast Wednesday at 12:48 PM

I don’t think you want to do this for files you’ve opened for writing.

In fact it’s quite common to “commit” on close, at least from what I’ve seen.

show 1 reply