The sync Go package contains functions that can help you synchronize goroutines; the most important functions of sync are sync.Add, sync.Done, and sync.Wait. The synchronization of goroutines is a mandatory task for every programmer.
Note that the synchronization of goroutines has nothing to do with shared variables and shared state. Shared variables and shared state have to do with the method you want to use for performing concurrent interactions.