3 ms·
To me, the trick with closing the resource sounds like a hack. Imagine you wanted to generalise it: We have a goroutine that may use some resources: sockets, f
by rumcajz 10y ago
To me, the trick with closing the resource sounds like a hack.
Imagine you wanted to generalise it: We have a goroutine that may use some resources: sockets, files, keyboard, screen etc. To shut it down you cut it off from all those resources and hope that it will die.
It sounds wrong somehow.
- jerf 10y agoI'd agree it was a hack if it were ill-defined, but I don't think it is. I don't think Go introduced that trick. In many cases you have to write your code to be able to deal with the resource being unavailable at any moment anyhow, especially networks, where Go is on its home turf. (As I've said more than once, the farther you are from writing something that looks like a network server, the less happy you will be with Go.)