Golang根据域名解析IP代码实现如下:

1
2
3
4
5
6
7
8
import "github.com/bogdanovich/dns_resolver"

resolver := dns_resolver.New([]string{"114.114.114.114", "114.114.115.115", "119.29.29.29", "223.5.5.5", "8.8.8.8", "208.67.222.222", "208.67.220.220"})    
resolver.RetryTimes = 5    
ip, err := resolver.LookupHost(remote[0])    
if err != nil {    
    log.Println(err)    
}