Skip to content

Instantly share code, notes, and snippets.

@pi3r
Created March 4, 2015 14:13
Show Gist options
  • Save pi3r/c33990a233552c21f28c to your computer and use it in GitHub Desktop.
Save pi3r/c33990a233552c21f28c to your computer and use it in GitHub Desktop.
func Stream(ctx context.Context, out <-chan Value) error {
for {
v, err := DoSomething(ctx)
if err != nil {
return err
}
select {
case <-ctx.Done():
return ctx.Err()
case out <- v:
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment