You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The GNU/Linux man nsswitch.conf is clear, as is the implementation: if there is no hosts line in /etc/nsswitch.conf, the default is "dns [!UNAVAIL=return] files". And that is what the net package implements.
The behavior you are seeing is not due to the net package handling of /etc/nsswitch.conf. It's due to how the C getaddrinfo function works. The C function calls inet_aton and inet_pton before checking either DNS or /etc/hosts. In other words, the C function is not doing a DNS lookup; it's first checking whether it has an IP address. If that's the behavior you want, call net.ParseIP.
I'm going to close this issue because it is not a bug.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
in remote DNS server
a.test.com reslove as 10.10.10.10
in /etc/hosts i hava a record
9.9.9.9 a.test.com
golang app will reslove a.test.com as 10.10.10.10
however ,
ping
curl
php app
java app
and so on will resolve a.test.com as 9.9.9.9What did you expect to see?
when /etc/nsswitch.conf doesn't exist ,Go's DNS use file first
in this , golang app should resolve a.test.com as 9.9.9.9
What did you see instead?
golang app will reslove a.test.com as 10.10.10.10
The text was updated successfully, but these errors were encountered: