One of the features which I would most love to see in Go is a Selectable interface, which could make things like this doable (albeit as a bit of a hack).
Even if a socket's Selectable implementation just abstracted away the goroutine from your first example, it would make the developer experience a lot nicer for me.
Even if a socket's Selectable implementation just abstracted away the goroutine from your first example, it would make the developer experience a lot nicer for me.