-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (35 loc) · 792 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
package main
import (
"fmt"
// "io/ioutil"
"log"
"os"
"ping_destination/pingerfolder"
"strconv"
"time"
)
func main() {
var d = 3000 * time.Microsecond
var t = time.Now().Add(d)
i := 1
for i <= 5 {
if time.Now().Before(t) {
continue
}
raw_result := pingerfolder.PingerThing()
sent := strconv.Itoa(raw_result.PacketsSent)
recv := strconv.Itoa(raw_result.PacketsSent)
addr := raw_result.Addr
fmt.Println("Sent = " + sent + " Received = " + recv + " Address = " + addr)
i++
f, err := os.OpenFile("results.txt",
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Println(err)
}
defer f.Close()
if _, err := f.WriteString("Sent = " + sent + " Received = " + recv + " Address = " + addr + "\n"); err != nil {
log.Println(err)
}
}
}