Skip to content

Commit

Permalink
Use log.Fatalf
Browse files Browse the repository at this point in the history
  • Loading branch information
miekg committed Mar 23, 2013
1 parent 7148471 commit dc6bfab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
8 changes: 3 additions & 5 deletions tutorial4/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"github.com/miekg/dns"
"github.com/miekg/unbound"
"os"
"log"
)

// This is called when resolution is completed.
Expand All @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions tutorial5/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 5 additions & 9 deletions tutorial6/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dc6bfab

Please sign in to comment.