Skip to content

Instantly share code, notes, and snippets.

@cideM
Created September 20, 2021 08:22
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 cideM/8a1159be34971820a46dd5d34f0ca955 to your computer and use it in GitHub Desktop.
Save cideM/8a1159be34971820a46dd5d34f0ca955 to your computer and use it in GitHub Desktop.
Add a delay
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