From dc6bfab214ce4d2b6668248fbda85c70983e980b Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 23 Mar 2013 11:00:17 +0000 Subject: [PATCH] Use log.Fatalf --- tutorial4/example.go | 8 +++----- tutorial5/example.go | 8 +++----- tutorial6/example.go | 14 +++++--------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/tutorial4/example.go b/tutorial4/example.go index 4b1f910..db41028 100644 --- a/tutorial4/example.go +++ b/tutorial4/example.go @@ -6,7 +6,7 @@ import ( "fmt" "github.com/miekg/dns" "github.com/miekg/unbound" - "os" + "log" ) // This is called when resolution is completed. @@ -29,13 +29,11 @@ func main() { done := make(chan *unbound.ResultError) if err := u.ResolvConf("/etc/resolv.conf"); err != nil { - fmt.Printf("error %s\n", err.Error()) - os.Exit(1) + log.Fatalf("error %s\n", err.Error()) } if err := u.Hosts("/etc/hosts"); err != nil { - fmt.Printf("error %s\n", err.Error()) - os.Exit(1) + log.Fatalf("error %s\n", err.Error()) } u.ResolveAsync("www.nlnetlabs.nl.", dns.TypeA, dns.ClassINET, done) diff --git a/tutorial5/example.go b/tutorial5/example.go index 996e535..9529fb2 100644 --- a/tutorial5/example.go +++ b/tutorial5/example.go @@ -6,7 +6,7 @@ import ( "fmt" "github.com/miekg/dns" "github.com/miekg/unbound" - "os" + "log" ) func main() { @@ -14,13 +14,11 @@ func main() { defer u.Destroy() if err := u.ResolvConf("/etc/resolv.conf"); err != nil { - fmt.Printf("error %s\n", err.Error()) - os.Exit(1) + log.Fatalf("error %s\n", err.Error()) } if err := u.Hosts("/etc/hosts"); err != nil { - fmt.Printf("error %s\n", err.Error()) - os.Exit(1) + log.Fatalf("error %s\n", err.Error()) } q := make(chan bool) // start two goroutines diff --git a/tutorial6/example.go b/tutorial6/example.go index f12ac6e..47b84f5 100644 --- a/tutorial6/example.go +++ b/tutorial6/example.go @@ -6,7 +6,7 @@ import ( "fmt" "github.com/miekg/dns" "github.com/miekg/unbound" - "os" + "log" ) func main() { @@ -14,24 +14,20 @@ func main() { defer u.Destroy() if err := u.ResolvConf("/etc/resolv.conf"); err != nil { - fmt.Printf("error %s\n", err.Error()) - os.Exit(1) + log.Fatalf("error %s\n", err.Error()) } if err := u.Hosts("/etc/hosts"); err != nil { - fmt.Printf("error %s\n", err.Error()) - os.Exit(1) + log.Fatalf("error %s\n", err.Error()) } if err := u.AddTaFile("keys"); err != nil { - fmt.Printf("error %s\n", err.Error()) - os.Exit(1) + log.Fatalf("error %s\n", err.Error()) } r, err := u.Resolve("nlnetlabs.nl.", dns.TypeA, dns.ClassINET) if err != nil { - fmt.Printf("error %s\n", err.Error()) - os.Exit(1) + log.Fatalf("error %s\n", err.Error()) } // show first result