Created
November 19, 2018 09:47
-
-
Save YashishDua/ce4c4bd52a5db473d82ded65c8dff6b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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