Skip to content

Instantly share code, notes, and snippets.

@xyhp915
Created April 3, 2014 14:42
Show Gist options
  • Save xyhp915/9955633 to your computer and use it in GitHub Desktop.
Save xyhp915/9955633 to your computer and use it in GitHub Desktop.
go play
package main
import (
"fmt"
)
func main() {
queue := []int{1, 2, 3, 4, 5}
ch := make(chan int)
go func() {
for _, val := range queue {
ch <- val
}
}()
var item int
for {
item = <-ch
if item == 5 {
fmt.Println("break loop")
break
} else {
fmt.Println(item)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment