Channel Factory and Producer-Consumer Pattern

This lesson provides detailed concepts on the channel factory and producer-consumer pattern.

Channel factory pattern

Another common pattern in this style of programming is that, instead of passing a channel as a parameter to a goroutine, the function makes the channel and returns it (so it plays the role of a factory). Inside the function, a lambda function is called a goroutine. The following code is an implementation of this pattern:

Get hands-on with 1400+ tech skills courses.