Skip to content

Instantly share code, notes, and snippets.

@horzu
Created March 17, 2022 19:50
Show Gist options
  • Save horzu/74d8e8b8f1f3c589e7e89e81bdf95d01 to your computer and use it in GitHub Desktop.
Save horzu/74d8e8b8f1f3c589e7e89e81bdf95d01 to your computer and use it in GitHub Desktop.
channels-2
package main
import (
"fmt"
"time"
)
func main() {
c := make(chan string)
go counter("first", c)
for {
msg := <- c
fmt.Println(msg)
}
}
func counter(rank string, c chan string) {
for i := 1; i <= 7; i++ {
//fmt.Println(i, rank)
c <- rank
time.Sleep(time.Second * 1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment