Skip to content

Instantly share code, notes, and snippets.

@YashishDua
Created November 19, 2018 09:47
Show Gist options
  • Save YashishDua/ce4c4bd52a5db473d82ded65c8dff6b0 to your computer and use it in GitHub Desktop.
Save YashishDua/ce4c4bd52a5db473d82ded65c8dff6b0 to your computer and use it in GitHub Desktop.
func generateMessage(message string) {
// Buffered Channel of type Boolean
done := make(chan bool, 1)
go printMessage(done, message)
// Waiting to receive value from channel
<-done
}
func printMessage(done chan bool, message string) {
defer func() {
// Sending value to channel
done <- true
} ()
// Inside Logic (Dont frighten xD)
if IsTimeEnabled {
log.Println(message)
return
}
fmt.Println(message)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment