func dnsReadConfig() (*dnsConfig, error) {
	file, err := os.Open("/etc/resolv.conf")
	if err != nil {
		return nil, &ConfigError{err}
	}
	defer file.Close()
	conf := new(dnsConfig)
	conf.servers = make([]string, 3)[0:0]  
	conf.search = make([]string, 0)
	conf.ndots = 1
	conf.timeout = 5
	conf.attempts = 2
	conf.rotate = false
	b := bufio.NewReader(file)
	for {
		line, err := b.ReadString('\n')
		if err != nil {
			break
		}
		f := strings.Fields(line)
		if len(f) < 1 {
			continue
		}
		switch f[0] {
		case "nameserver":  
			a := conf.servers
			n := len(a)
			if len(f) > 1 && n < cap(a) {
				name := f[1]
				switch len(net.ParseIP(name)) {
				case 16:
					name = "[" + name + "]"
					fallthrough
				case 4:
					a = a[0 : n+1]
					a[n] = name
					conf.servers = a
				}
			}
		case "domain":  
			if len(f) > 1 {
				conf.search = make([]string, 1)
				conf.search[0] = f[1]
			} else {
				conf.search = make([]string, 0)
			}
		case "search":  
			conf.search = make([]string, len(f)-1)
			for i := 0; i < len(conf.search); i++ {
				conf.search[i] = f[i+1]
			}
		case "options":  
			for i := 1; i < len(f); i++ {
				s := f[i]
				switch {
				case len(s) >= 6 && s[0:6] == "ndots:":
					n, _ := strconv.Atoi(s[6:])
					if n < 1 {
						n = 1
					}
					conf.ndots = n
				case len(s) >= 8 && s[0:8] == "timeout:":
					n, _ := strconv.Atoi(s[8:])
					if n < 1 {
						n = 1
					}
					conf.timeout = n
				case len(s) >= 8 && s[0:9] == "attempts:":
					n, _ := strconv.Atoi(s[9:])
					if n < 1 {
						n = 1
					}
					conf.attempts = n
				case s == "rotate":
					conf.rotate = true
				}
			}
		}
	}
	return conf, nil
}
See resolv.conf(5) on a Linux machine.
TODO(rsc): Supposed to call uname() and chop the beginning
of the host name to get the default search domain.
We assume it's in resolv.conf anyway.
package dns
import (
	"bufio"
	"net"
	"os"
	"strconv"
	"strings"
)
type dnsConfig struct {
	servers  []string  
	search   []string  
	ndots    int       
	timeout  int       
	attempts int       
	rotate   bool      
}