News for hackers. Stuff that matters.
Re:Go Is on a Trajectory to Become the Next Enterprise Progr... by tonyarkles on Thursday May 09, 2019 @07:22PM (#19873498)
It’s been a while since I’ve been writing Go, but wasn’t that nominally what the Context objects were supposed to be for? I think they were introduced a bit late in the game, but APIs that supported them handled cancellation well (if I’m remembering right)
Re:Go Is on a Trajectory to Become the Next Enterprise Progr... by owaislone on Thursday May 09, 2019 @07:57PM (#19873733)
Context would be passed to each go-routines for cancellation but the pattern would be the same as OP's suggestion. I'd say a set of go-routines and a sync.WaitGroup would probably be a better pattern for this use case. Routines + select is more useful for listening on incoming data than concurrently sending out bytes.