Categorygithub.com/resonatehq/gocoro
repositorypackage
0.0.0-20240928015848-78539a59dab0
Repository: https://github.com/resonatehq/gocoro.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author

# README

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.