Skip to content

Instantly share code, notes, and snippets.

@cideM
Created September 20, 2021 08:21
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/a9de1dd2c5845232833308124d03a7df to your computer and use it in GitHub Desktop.
Save cideM/a9de1dd2c5845232833308124d03a7df to your computer and use it in GitHub Desktop.
Fix the first deadlock
diff --git a/main.go b/main.go
index 92bcd33..5c20c9f 100644
--- a/main.go
+++ b/main.go
@@ -7,9 +7,12 @@ import (
func producer(strings []string) (<-chan string, error) {
outChannel := make(chan string)
- for _, s := range strings {
- outChannel <- s
- }
+ go func() {
+
+ for _, s := range strings {
+ outChannel <- s
+ }
+ }()
return outChannel, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment