Created
March 4, 2015 14:13
-
-
Save pi3r/c33990a233552c21f28c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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