Skip to content
coroutine , async/await for golang
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
coutil
demo co: add some code Oct 5, 2016
.gitignore co: add some code Oct 5, 2016
CHANGELOG.md co: add changelog & version Oct 5, 2016
README.md co: add ref to changelog Oct 5, 2016
co.go co: add some code Oct 5, 2016
glide.lock glide: nice tool Aug 3, 2016
glide.yaml
task.go co: add some code Oct 5, 2016
vars.go co: add changelog & version Oct 5, 2016

README.md

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 (magicdawn@qq.com)

You can’t perform that action at this time.