選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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. }