Skip to content

Instantly share code, notes, and snippets.

@7yan00
Created October 22, 2014 04:12
Show Gist options
  • Save 7yan00/871fdb0877cec09f23bf to your computer and use it in GitHub Desktop.
Save 7yan00/871fdb0877cec09f23bf to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
chanel := make(chan int)
go func(s chan<- int) {
for i := 1 i < 5; i++ {
s <- i
}
close(s)
}(chanel)
for {
value, ok := <-chanel
if ok {
break
}
fmt.Println(value)
fmt.Println("hogehoge")
}
}
package main
import "fmt"
func main() {
chanel := make(chan int)
go func(s chan<- int) {
for i := 1 i < 5; i++ {
s <- i
}
close(s)
}(chanel)
for {
value, ok := <-chanel
if ok {
break
}
fmt.Println(value)
fmt.Println("hogehoge")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment