Created
September 20, 2021 08:22
-
-
Save cideM/8a1159be34971820a46dd5d34f0ca955 to your computer and use it in GitHub Desktop.
Add a delay
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
diff --git a/main.go b/main.go | |
index 638af00..af15140 100644 | |
--- a/main.go | |
+++ b/main.go | |
@@ -2,6 +2,7 @@ package main | |
import ( | |
"log" | |
+ "time" | |
) | |
func producer(strings []string) (<-chan string, error) { | |
@@ -10,6 +11,7 @@ func producer(strings []string) (<-chan string, error) { | |
go func() { | |
defer close(outChannel) | |
for _, s := range strings { | |
+ time.Sleep(time.Second * 3) | |
outChannel <- s | |
} | |
}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment