Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(73)

Unified Diff: 2014/openlate/chan.go

Issue 138320043: go.talks: Talk at OpenDNS
Patch Set: diff -r 7094cf573469ad6baa128f4c67e970f044a53338 https://code.google.com/p/go.talks Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « 2014/openlate/battle.go ('k') | 2014/openlate/conc1.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: 2014/openlate/chan.go
===================================================================
new file mode 100644
--- /dev/null
+++ b/2014/openlate/chan.go
@@ -0,0 +1,26 @@
+// +build OMIT
+
+package main
+
+import (
+ "fmt"
+ "time"
+)
+
+func sleepAndTalk(secs time.Duration, msg string, c chan string) {
+ time.Sleep(secs * time.Second)
+ c <- msg
+}
+
+func main() {
+ c := make(chan string)
+
+ go sleepAndTalk(0, "Hello", c)
+ go sleepAndTalk(1, "Gophers!", c)
+ go sleepAndTalk(2, "What's", c)
+ go sleepAndTalk(3, "up?", c)
+
+ for i := 0; i < 4; i++ {
+ fmt.Printf("%v ", <-c)
+ }
+}
« no previous file with comments | « 2014/openlate/battle.go ('k') | 2014/openlate/conc1.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b