I've set up a development environment on my MacBook Pro M1 (running Big Sur 11.2.3, Go 1.16.2) with a number of small Go/.Net HTTP APIs that are communication with each other. To replicate our production infrastructure I've set up /etc/hosts with ".local" domains pointing to 127.0.0.1. An nginx server then proxies the requests to the APIs. A self signed certificate is used for https.
Whenever an HTTP request is sent from a Go application to any of the ".local" APIs, 5 seconds are added to the response time. This delay is not added when I use a browser to make the request, neither if I call an external address (for example
google.com) or "localhost" from the Go code. It only happens when I use http.Client to request a ".local" domain and the behavior is consistent.
I've searched the Go standard library for a "5 * time.Second" and found it only in a few places, including src/net/dnsconfig_unix.go so I guess it's related to the name resolution.
Anyone got an idea about what's wrong and how it can be fixed?
/Jonathan