Permalink
Browse files

Use log.Fatalf

  • Loading branch information...
1 parent 7148471 commit dc6bfab214ce4d2b6668248fbda85c70983e980b @miekg committed Mar 23, 2013
Showing with 11 additions and 19 deletions.
  1. +3 −5 tutorial4/example.go
  2. +3 −5 tutorial5/example.go
  3. +5 −9 tutorial6/example.go
View
@@ -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)
View
@@ -6,21 +6,19 @@ import (
"fmt"
"github.com/miekg/dns"
"github.com/miekg/unbound"
- "os"
+ "log"
)
func main() {
u := unbound.New()
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
View
@@ -6,32 +6,28 @@ import (
"fmt"
"github.com/miekg/dns"
"github.com/miekg/unbound"
- "os"
+ "log"
)
func main() {
u := unbound.New()
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

0 comments on commit dc6bfab

Please sign in to comment.