Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Right, but be careful, if you execute that in the <-x case you just created a totally different memory leak since there won't be any more values coming down that channel. The only reason the timeout channel itself is safe is because the channel is buffered. Which incidentally is a good way to handle this particular example: make a buffer of size 1, and then be sure to never ever send more than 1 value.

This is kind of my point: with Go's concurrency, all the contracts are implicit and dangerous, exactly the kind of thing that are supposed to be solved by a good type system and garbage collection (incidentally, Go gets all of that stuff right).



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: