Skip to content

Instantly share code, notes, and snippets.

@zaz600
Last active February 23, 2021 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zaz600/af6c5e783fcca5f75238 to your computer and use it in GitHub Desktop.
Save zaz600/af6c5e783fcca5f75238 to your computer and use it in GitHub Desktop.
web_check
// web_check.go
package main
import (
"fmt"
"net/http"
)
const url = "https://golang.org/"
func main() {
check(url)
}
func check(url string) {
fmt.Println("Проверяем адрес ", url)
resp, err := http.Get(url)
if err != nil {
fmt.Printf("Ошибка соединения. %s\n", err)
return
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
fmt.Printf("Ошибка. http-статус: %s\n", resp.StatusCode)
return
}
fmt.Printf("Онлайн. http-статус: %d\n", resp.StatusCode)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment