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

One feedback: I skimmed through the Context chapter and noticed that you made the common mistake.

In the code snippet provided at https://www.practical-go-lessons.com/chap-37-context#the-ser..., you made the channel unbuffered. The doWork goroutine would write to the channel and the "main" goroutine would read from it. But since the "main" goroutine could exit early because of context cancellation, they could get into the case of no one on the reading end any more, causing the doWork goroutine to be blocked forever (the writing to the channel is blocked when there's no one to read it).

Someone even published a paper about fixing this common mistake in open source projects a few days ago: https://www.reddit.com/r/golang/comments/m66djp/automaticall...



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

Search: