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/0e6ab02f9abc6830430ae4d4e9e4bf36 to your computer and use it in GitHub Desktop.
Save cideM/0e6ab02f9abc6830430ae4d4e9e4bf36 to your computer and use it in GitHub Desktop.
Fix the second deadlock
diff --git a/main.go b/main.go
index 5c20c9f..638af00 100644
--- a/main.go
+++ b/main.go
@@ -8,7 +8,7 @@ func producer(strings []string) (<-chan string, error) {
outChannel := make(chan string)
go func() {
-
+ defer close(outChannel)
for _, s := range strings {
outChannel <- s
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment