golang内置的http客户端默认会缓存tcp连接, 官方文档也说到了这个需要注意的地方:

A Client is an HTTP client. Its zero value (DefaultClient) is a usable client that uses DefaultTransport.

The Client’s Transport typically has internal state (cached TCP connections), so Clients should be reused instead of created as needed. Clients are safe for concurrent use by multiple goroutines.

A Client is higher-level than a RoundTripper (such as Transport) and additionally handles HTTP details such as cookies and redirects.

大多数情况下这个缓存没有问题,在某些场景下则需要考虑缓存的因素,比如线上的服务A需要访问http://service.com 的服务, 由于某种原因service.com服务的原部署机器需要下线,这时候我们一般是先在新服务器部署好service.com服务,然后变更service.com的dns记录,让service.com指向新的服务器ip,但是由于缓存的原因这时候服务A访问的service.com还是老的ip,新的地址并未生效,所以最终还是需要重启服务A。