Created
March 20, 2015 10:51
-
-
Save quii/913d27d87e9a430acc2c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Stitcher calls the Hello and World APIs to create a very useful string | |
func Stitcher(helloURL string, worldURL string) string { | |
helloChannel := make(chan []byte, 1) | |
worldChannel := make(chan []byte, 1) | |
go func() { | |
helloResponse, _ := http.Get(helloURL) | |
defer helloResponse.Body.Close() | |
helloContent, _ := ioutil.ReadAll(helloResponse.Body) | |
helloChannel <- helloContent | |
}() | |
go func() { | |
worldResponse, _ := http.Get(worldURL) | |
defer worldResponse.Body.Close() | |
worldContent, _ := ioutil.ReadAll(worldResponse.Body) | |
worldChannel <- worldContent | |
}() | |
return string(<-helloChannel) + ", " + string(<-worldChannel) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment