Skip to content

Instantly share code, notes, and snippets.

@cideM
Last active September 8, 2022 12:26
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/44c194c25abb4b38d0aaf8b9b87d1c3a to your computer and use it in GitHub Desktop.
Save cideM/44c194c25abb4b38d0aaf8b9b87d1c3a to your computer and use it in GitHub Desktop.
Fix the empty logs
diff --git a/main.go b/main.go
index c45418b..dd7d1ef 100644
--- a/main.go
+++ b/main.go
@@ -31,9 +31,10 @@ func sink(ctx context.Context, values <-chan string) {
log.Print(ctx.Err().Error())
return
case val, ok := <-values:
- log.Println(val)
if ok {
log.Printf("sink: %s", val)
+ } else {
+ return
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment