Skip to content
/ goco Public

async/await, thread safe coroutine for golang

Notifications You must be signed in to change notification settings

lsg2020/goco

Repository files navigation

goco

async/await, thread safe coroutine for golang

usage

  • create corotuine
coroutine, err := co.New(&co.Options{Name: "test"})
  • run coroutine task in goroutine
amount := 0
err := coroutine.RunAsync(ctx, func(ctx context.Context) error {
    for i := 0; i<10; i++ {
        amount++ // thread safe
        co.Sleep(ctx, time.Second)
    }
    return nil
}, nil)

result := coroutine.RunSync(ctx, func(ctx context.Context) error {
    for i := 0; i<10; i++ {
        amount++ // thread safe
        co.Sleep(ctx, time.Second)
    }
    return nil
}, nil)

About

async/await, thread safe coroutine for golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages