Fan-In, Fan-Out
Explore how to use Fan-In and Fan-Out techniques in Go to merge multiple data inputs into a single channel and split data across multiple goroutines. Understand how these patterns improve concurrency by resolving blocking operations and distributing workload effectively.
We'll cover the following...
Fan-In refers to a technique in which you join data from multiple inputs into a single entity. On the other hand, Fan-Out means to divide the data from a single source into multiple smaller chunks. In this lesson, we’ll learn how to make use of both these techniques.
The code below is from the previous lesson where two receiving operations were blocking each other.
fmt.Println(<-positionChannel1)
fmt.Println(<-positionChannel2)
These operations were taking turns not only in printing value on to the console but also in proceeding to the next computation. ...