Skip to content

Instantly share code, notes, and snippets.

@songrgg
Last active July 3, 2017 01:48
Show Gist options
  • Save songrgg/cc6d9cad7d7e2da0ec61119a8ff24982 to your computer and use it in GitHub Desktop.
Save songrgg/cc6d9cad7d7e2da0ec61119a8ff24982 to your computer and use it in GitHub Desktop.
Call API1 & API2 concurrently
package main
import (
"fmt"
"sync"
)
func main() {
var wt sync.WaitGroup
wt.Add(2)
var response1 string
var response2 string
go func() {
// fetch API1
response1 := ""
wt.Done()
}()
go func() {
// fetch API2
response2 := ""
wt.Done()
}()
fmt.Println("return merged response: ", response1+response2)
wt.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment