Skip to content

Commit

Permalink
adds student goroutine printing question
Browse files Browse the repository at this point in the history
  • Loading branch information
GoesToEleven committed Jan 16, 2016
1 parent ddaf48c commit 8182e35
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 23_QUESTIONS-FROM-STUDENTS/02-goroutines-printing/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import "fmt"

func main() {
c := make(chan int)

go func() {
for i := 0; i < 10; i++ {
fmt.Println("In goroutine:", i)
c <- i
}
close(c)
}()

for n := range c {
fmt.Println("In main: ", n)
}
}

0 comments on commit 8182e35

Please sign in to comment.