Created
August 31, 2015 13:39
-
-
Save zgiber/60aeb349559573210774 to your computer and use it in GitHub Desktop.
Iterating 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
package main | |
import "fmt" | |
import "time" | |
func main() { | |
pr := make(chan interface{}) | |
go runme(pr) | |
for _ = range pr { | |
fmt.Print(".") | |
} | |
fmt.Print("x") | |
} | |
func runme(pr chan interface{}) { | |
for i := 0; i < 100; i++ { | |
time.Sleep(10 * time.Millisecond) | |
pr <- nil | |
} | |
close(pr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment