Skip to content

Instantly share code, notes, and snippets.

@ngurajeka
Last active May 22, 2020 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngurajeka/c8573812df2d99165d3bf7f9daca0174 to your computer and use it in GitHub Desktop.
Save ngurajeka/c8573812df2d99165d3bf7f9daca0174 to your computer and use it in GitHub Desktop.
package main
import (
"log"
"net/http"
)
func main() {
urls := []string{
"https://github.com",
"https://api.github.com",
"https://google.com",
"https://ngurajeka.com",
}
for _, url := range urls {
resp, err := http.Get(url)
if err != nil {
log.Printf("%s got err: %s", url, err.Error())
continue
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
log.Printf("%s get error code: %d", url, resp.StatusCode)
continue
}
log.Printf("%s looks fine", url)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment