Closed pantelis-karamolegkos closed 6 months ago
Probably
if t, ok := in.Answer[i].(*dns.A); ok {
fmt.Println(t.A.String())
}
good suggestion; I see that it prints something in the likes of
185.6.76.42
185.6.76.42
Is there an inherent library way of getting this either as a []netIP
or at least []string
or do I have to resort to manual parsing?
(and I don't get why it fetches twice the same A record)
Is there an inherent library way of getting this either as a []netIP or at least []string or do I have to resort to manual parsing?
The t.A
from @rdrozhdzh' comment is a net.IP
. To get it into an array, though, you'll have to write a loop yourself, since you're combining data from multiple records.
(and I don't get why it fetches twice the same A record)
It shouldn't and doesn't for me. Did you remove the fmt.Println
you already had in your initial code above?
I just want to get / print the IPs / A records of a simple query.
Is there a more idiomatic way of going about it, rather than splitting the answer as per the example below