I recently started using channels and concurrecny in Go and updated a project's code to this:
c := make(chan []MetaFollow, 3)
var wg sync.WaitGroup
wg.Add(3)
go Mutuals(followers, following, c, &wg)
mutuals := <-c
go IDontFollow(followers, following, c, &wg)
iDontFollow := <-c
go TheyDontFollow(followers, following, c, &wg)
theyDontFollow := <-c
wg.Wait()
How does Go ensures that the variable gets the exact same data as generated by it's above function? In the buffered channel case.