Search code examples
javascriptnode.jsgogeneratorgoroutine

How are Go channels different from JavaScript generators?


Go channels can be used to communicate in between goroutines. Similarly, the yield and next syntax can be used to communicate between two generators. Am I right in my assumption? If not, where am I wrong?


Solution

  • A channel in Go is a general, multipurpose tool for communication between goroutines. It can be used to create a concurrent generator.

    The yield keyword is a very specific tool that let you easily create a nonconcurrent generator.