Here is an example program that uses goroutines and channels.
It fetches several web pages simultaneously using the net/http package, and prints the URL of the biggest home page.
package main /*from w w w. j a v a 2s . com*/ import ( "fmt" "io/ioutil" "net/http" ) type HomePageSize struct { URL string Size int } func main() { urls := []string{ "http://www.apple.com", "http://www.amazon.com", "http://www.google.com", "http://www.microsoft.com", } results := make(chan HomePageSize) for _, url := range urls { go func(url string) { res, err := http.Get(url) if err != nil { panic(err) } defer res.Body.Close() bs, err := ioutil.ReadAll(res.Body) if err != nil { panic(err) } results <- HomePageSize{ URL: url, Size: len(bs), } }(url) } var biggest HomePageSize for range urls { result := <-results if result.Size > biggest.Size { biggest = result } } fmt.Println("The biggest home page:", biggest.URL) }