Created
May 8, 2020 19:55
-
-
Save ankur22/b2c77c3576c09ace9a6706ca0c0390ae to your computer and use it in GitHub Desktop.
Using range over a channel
This file contains 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
eg.Go(func() error { | |
for l := range lines { | |
select { | |
case <-ctx.Done(): | |
fmt.Println("Sender: Context closed") | |
return ctx.Err() | |
default: | |
fmt.Printf("Sender: Sending %s to remote database\n", l) | |
} | |
} | |
return nil | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment