Last active
July 3, 2017 01:48
-
-
Save songrgg/cc6d9cad7d7e2da0ec61119a8ff24982 to your computer and use it in GitHub Desktop.
Call API1 & API2 concurrently
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
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