All Projects → magicdawn → go-co

magicdawn / go-co

Licence: other
coroutine , async/await for golang

Programming Languages

go
31211 projects - #10 most used programming language

go-co

GoDoc

coroutine , async/await for golang

Goals

to simulate

  • yield/Promise in node.js, co
  • async/await/Task in C#

checkout blog http://magicdawn.ml/2015/01/10/generator-and-promise/

Install

with glide

$ glide get github.com/magicdawn/go-co

API

co

import "github.com/magicdawn/go-co"
  • co.Task : similar to Task in .NET,stands for a samll piece of work

  • co.Await: await a Task

    result,err := co.Await(task)
  • co.Async: make a Task

    func sleep() *co.Task{
    	return co.Async(func() interface{}{
        	time.sleep(time.Seconds * 10)
            return nil
        })
    }

    here is a Task will need 10 seconds

coutil

  • coutil.Each : like Promise.each
  • coutil.Map : like Promise.map with concurrency support

more checkout demo/ directory

CHANGELOG

CHANGELOG.md

License

the MIT license ([email protected])

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].