Created
September 27, 2021 15:16
-
-
Save Israel-Miles/a909ccf206ae8ffb6d27cf3186b5082d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
var wg sync.WaitGroup | |
channel := make(chan string) | |
wg.Add(2) | |
go func(channel chan string, wg *sync.WaitGroup) { | |
defer wg.Done() | |
fmt.Println(<-channel) | |
}(channel, &wg) | |
go func(channel chan string, wg *sync.WaitGroup) { | |
defer wg.Done() | |
channel <- "Sending message to channel" | |
}(channel, &wg) | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment