Last active
May 22, 2020 09:20
-
-
Save ngurajeka/4f4ee2c054b38512dc6d3198910e5cfa 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
package main | |
import ( | |
"log" | |
"net/http" | |
"sync" | |
) | |
func main() { | |
urls := []string{ | |
"https://github.com", | |
"https://api.github.com", | |
"https://google.com", | |
"https://ngurajeka.com", | |
"https://meraxes.id", | |
"https://valutac.com", | |
"https://teams.microsoft.com", | |
"https://facebook.com", | |
"https://twitter.com", | |
} | |
var wg sync.WaitGroup | |
for _, url := range urls { | |
wg.Add(1) | |
go func(v string) { | |
defer wg.Done() | |
resp, err := http.Get(v) | |
if err != nil { | |
log.Printf("%s got err: %s", v, err.Error()) | |
return | |
} | |
defer resp.Body.Close() | |
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated { | |
log.Printf("%s get error code: %d", v, resp.StatusCode) | |
return | |
} | |
log.Printf("%s looks fine", v) | |
}(url) | |
} | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment