Skip to content

Instantly share code, notes, and snippets.

@emretanriverdi
Created January 17, 2021 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emretanriverdi/62e78651ff15a4aecc91e36e75555a12 to your computer and use it in GitHub Desktop.
Save emretanriverdi/62e78651ff15a4aecc91e36e75555a12 to your computer and use it in GitHub Desktop.
select-channel.go
func main() {
c1 := make(chan string)
c2 := make(chan string)
go invalidateCrucial(c1)
go invalidateNotSoCruical(c2)
for {
fmt.Println(<-c1)
fmt.Println(<-c2)
}
}
func invalidateCrucial(c chan string) {
for {
time.Sleep(time.Second * 5)
c <- "Every 5sec"
}
}
func invalidateNotSoCruical(c chan string) {
for {
time.Sleep(time.Second * 30)
c <- "Every 30sec"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment