/
main.go
44 lines (33 loc) · 836 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"net"
"github.com/franela/goreq"
)
func main() {
fmt.Println("starting")
fmt.Println("google.com:80")
_, err := net.Dial("tcp", "google.com:80")
printerr(err)
fmt.Println("github.com:443")
_, err = net.Dial("tcp", "github.com:443")
printerr(err)
fmt.Println("http://github.com")
_, err = goreq.Request{Uri: "http://www.github.com"}.Do()
printerr(err)
fmt.Println("https://github.com")
_, err = goreq.Request{Uri: "https://www.github.com"}.Do()
printerr(err)
fmt.Println("http://google.com")
_, err = goreq.Request{Uri: "http://www.google.com"}.Do()
printerr(err)
fmt.Println("https://google.com")
_, err = goreq.Request{Uri: "https://www.google.com"}.Do()
printerr(err)
fmt.Println("done")
}
func printerr(err error) {
if err != nil {
fmt.Printf("error: %s\n", err)
}
}