Skip to content

Instantly share code, notes, and snippets.

@kardolus
Last active May 24, 2019 15:25
Show Gist options
  • Save kardolus/f7398dcf88affe41541cafe681775b76 to your computer and use it in GitHub Desktop.
Save kardolus/f7398dcf88affe41541cafe681775b76 to your computer and use it in GitHub Desktop.
Concurrency Ideas
package main
import (
"fmt"
)
func main() {
pingchan := make(chan string)
// Have a channel per callout group
go func() {
result := Sequential()
pingchan <- result
}()
// Do the other concurrent calls here
// ...
// Then receive all the results, may as well be one by one
received := <-pingchan
fmt.Println(received)
}
func Sequential() string {
return "In Sequence"
}
package main
import (
"fmt"
)
func main() {
pingchan := make(chan string)
go ping(pingchan)
received := <-pingchan
fmt.Println(received)
}
func ping(message chan string) {
message <- "ping"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment