Created
April 30, 2015 13:51
-
-
Save ekoecho/c00dbc48b883799e76f7 to your computer and use it in GitHub Desktop.
This file contains 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" | |
) | |
func main() { | |
var status string | |
conn, err := net.Dial("tcp", "127.0.0.1:80") | |
if err != nil { | |
log.Println("Connection error:", err) | |
status = "Unreachable" | |
} else { | |
status = "Online" | |
defer conn.Close() | |
} | |
log.Println(status) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/akutz/gotil/blob/master/gotil.go#L284