Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "net/http"
- )
- func main() {
- links := []string{
- "http://google.com",
- "http://yahoo.com",
- "http://sportacentrs.com",
- "http://golang.org",
- "http://facebook.com",
- }
- c := make(chan string)
- for _, link := range links {
- go checkLink(link, c)
- }
- for l := range c {
- go checkLink(l, c)
- }
- }
- func checkLink(link string, c chan string) {
- _, err := http.Get(link)
- if err != nil {
- fmt.Println(link, "might be down!")
- c <- link
- return
- }
- fmt.Println(link, "is up!")
- c <- link
- }
Advertisement
Add Comment
Please, Sign In to add comment