The channel acts as a pipe by which we send typed values from one Goroutine to another. It guarantees synchronization since only one Goroutine has access to a data item at any given time. The ownership of the data is passed between different Goroutine. Hence, By design it avoids the pitfalls of shared memory and prevent race condition.
Go Channel Example