From f930d86dae662a6df1540ce1118cf8c994f13145 Mon Sep 17 00:00:00 2001 From: Tatsushi Demachi Date: Sun, 3 Aug 2014 18:23:10 +0900 Subject: [PATCH] Fix documents --- README.md | 17 ++++++++++++++--- fastping.go | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1fb02fc..834e106 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,24 @@ if err != nil { os.Exit(1) } p.AddIPAddr(ra) -p.AddHandler("receive", func(addr *net.IPAddr, rtt time.Duration) { +err = p.AddHandler("receive", func(addr *net.IPAddr, rtt time.Duration) { fmt.Printf("IP Addr: %s receive, RTT: %v\n", addr.String(), rtt) }) -p.AddHandler("idle", func() { +if err != nil { + fmt.Println(err) + os.Exit(1) +} +err = p.AddHandler("idle", func() { fmt.Println("finish") }) -p.Run() +if err != nil { + fmt.Println(err) + os.Exit(1) +} +err = p.Run() +if err != nil { + fmt.Println(err) +} ``` It sends an ICMP packet and wait a response. If it receives a response, it diff --git a/fastping.go b/fastping.go index 69838df..fcf5ec7 100644 --- a/fastping.go +++ b/fastping.go @@ -15,13 +15,24 @@ // os.Exit(1) // } // p.AddIPAddr(ra) -// p.AddHandler("receive", func(addr *net.IPAddr, rtt time.Duration) { +// err = p.AddHandler("receive", func(addr *net.IPAddr, rtt time.Duration) { // fmt.Printf("IP Addr: %s receive, RTT: %v\n", addr.String(), rtt) // }) -// p.AddHandler("idle", func() { +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } +// err = p.AddHandler("idle", func() { // fmt.Println("finish") // }) -// p.Run() +// if err != nil { +// fmt.Println(err) +// os.Exit(1) +// } +// err = p.Run() +// if err != nil { +// fmt.Println(err) +// } // // It sends an ICMP packet and wait a response. If it receives a response, // it calls "receive" callback. After that, MaxRTT time passed, it calls