Original post

func Resolver(r *dnsResolver, buffer chan string, wg *sync.WaitGroup) {
        defer wg.Done()
        r.mu.Lock()
        for hostname := range buffer {
                ips, err := net.LookupIP(hostname)
                if err != nil {
                        fmt.Fprintf(os.Stderr, "dnslookup error: %sn", hostname)
                }
                if len(ips) > 0 {

                        fmt.Fprintf(r.of, "%s %sn", hostname, ips[0].String())

                } else {
                        fmt.Fprintf(r.of, "%s n", hostname)
                }

        }
        r.mu.Unlock()

}



go run multi-lookup.go input/names1.txt input/names2.txt input/names3.txt input/names4.txt input/names5.txt results.txt
dnslookup error: sdjjdsaf.com
dnslookup error: 56.com
dnslookup error: sogou.com
dnslookup error: renren.com
dnslookup error: paipai.com
dnslookup error: tianya.cn
dnslookup error: kugou.com
dnslookup error: youdao.com
dnslookup error: pconline.com.cn
dnslookup error: sohu.com
dnslookup error: soso.com
dnslookup error: sina.com.cn