You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

channels.go 219B

12345678910111213
  1. package common
  2. // Last returns the last value received from the channel before it was closed
  3. func Last(channel <-chan int) (res int) {
  4. for {
  5. o, more := <-channel
  6. if more {
  7. res = o
  8. } else {
  9. return
  10. }
  11. }
  12. }