Last active
March 17, 2022 19:40
-
-
Save horzu/441456bca8cec0fabe999d6bc3919b88 to your computer and use it in GitHub Desktop.
channels-1
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
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
c := make(chan string) | |
go counter("first", c) | |
msg := <- c | |
fmt.Println(msg) | |
} | |
func counter(rank string, c chan string) { | |
for i := 1; i <= 7; i++ { | |
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