Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "net/http"
- "time"
- )
- func main() {
- links := []string{
- "http://sportacentrs.com",
- "http://tvnet.lv",
- "unknown website",
- "http://google.com",
- }
- c := make(chan string)
- for _, n := range links {
- go checkLink(n, c)
- }
- for li := range c {
- go func(self string) {
- time.Sleep(5 * time.Second)
- checkLink(self, c)
- }(li)
- }
- }
- func checkLink(link string, c chan string) {
- _, err := http.Get(link)
- if err != nil {
- fmt.Println(link, "didnt work.")
- c <- link
- return
- }
- fmt.Println(link, "worked.")
- c <- link
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement