Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 638 Bytes

README.md

File metadata and controls

30 lines (21 loc) · 638 Bytes

gocoro

A coroutine library for go that supports async await semantics.

Usage

return func(c *gocoro.Coroutine[func() (string, error), string, string]) (string, error) {

  // yield a function
  p := gocoro.Yield(c, func() (string, error) {
    return "foo", nil
  })

  // yield a coroutine
  c := gocoro.Spawn(c, func(c *gocoro.Coroutine[func() (string, error), string, string]) (string, error) {
    return "bar", nil
  })

  // await function
  foo, _ := gocoro.Await(c, p)

  // await coroutine
  bar, _ := gocoro.Await(c, c)

  return foo + bar, nil
}

See the example for complete usage details.