4 ms·
Not that I dont believe there are any, but I'd love to hear your perspective... Go (golang)
by maerF0x0 6y ago
Not that I dont believe there are any, but I'd love to hear your perspective...
Go (golang)
- crimper 6y agochannel programming and the races caused by closing channels. channels seem nice and easy until they don’t. the whole var/:=/= assignment combined with the error handling style and the shorthand is another one
- maerF0x0 6y agoyeah the lack of determinism in selecting a channel can be tricky for causing bugs where order matters. Luckily in smaller cases you're likely to encounter them as flakey tests (eg 1/2 the time) select { case <-ch1: case <-ch2: }
- crimper 6y agothanks for this, i couldn’t articulate it so clearly. Another gotcha is responding to closed channels, it makes sense in the grand scheme of things but when the program grows it gets tricky
- dpatterbee 6y agoOnly close channels when trying to tell the receiver that you're not sending more data. Otherwise let the garbage collector deal with it. Channels seem easy until they don't until they do again in my experience. Don't understand your second point.
- SavantIdiot 6y agoWell, shit. Got me there.
- boolemancer 6y agodefer having function scope instead of, well, scope scope. Using defer to unlock locks can lead to some fun deadlocks if you don't realize the issue with the scope, and it's completely unintuitive to someone with experience with other implementations of similar concepts.