工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.wdlinux.cn 注册 | 登陆

匿名无限循环

 // Creates an infinite stream of integers counting up from 1

func createCounter() <-chan int {
    result := make(chan int)
    go func() {
        var n int
        for {
            n++
            result <- n
        }
    }()
    return result
}

« 上一篇 | 下一篇 »

Trackbacks

点击获得Trackback地址,Encode: UTF-8

发表评论

评论内容 (必填):