https://github.com/bogdanovich/dns_resolver
Simple dns resolver in Go based on miekg/dns.
https://github.com/bogdanovich/dns_resolver
dns dns-resolver go golang
Last synced: 5 months ago
JSON representation
Simple dns resolver in Go based on miekg/dns.
- Host: GitHub
- URL: https://github.com/bogdanovich/dns_resolver
- Owner: bogdanovich
- License: mit
- Created: 2015-09-01T06:03:08.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-10-17T02:08:56.000Z (over 1 year ago)
- Last Synced: 2025-08-13T19:07:46.087Z (10 months ago)
- Topics: dns, dns-resolver, go, golang
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 76
- Watchers: 3
- Forks: 29
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple dns resolver implemented in go
[](https://travis-ci.org/bogdanovich/dns_resolver)
[](https://gowalker.org/github.com/bogdanovich/dns_resolver)
Based on based on miekg/dns.
## Features
- Uses provided dns servers array in random order
- Retries dns requests in case of i/o timeout
## Installing
### Using *go get*
$ go get github.com/bogdanovich/dns_resolver
After this command *dns_resolver* is ready to use. Its source will be in:
$GOPATH/src/github.com/bogdanovich/dns_resolver
## Example
``` go
package main
import (
"log"
"github.com/bogdanovich/dns_resolver"
)
func main() {
resolver := dns_resolver.New([]string{"8.8.8.8", "8.8.4.4"})
// OR
// resolver := dns_resolver.NewFromResolvConf("resolv.conf")
// In case of i/o timeout
resolver.RetryTimes = 5
ip, err := resolver.LookupHost("google.com")
if err != nil {
log.Fatal(err.Error())
}
log.Println(ip)
// Output [216.58.192.46]
}
```