Golang when to use DefaultHTTPClient and when custom?
- User
Golang when to use DefaultHTTPClient and when custom?
- Assistant
- User
And the HTTP client should be re-used right?
- Assistant
Yes, in Go,
http.Clientinstances should generally be reused and not created per request.Why reuse
http.Client?-
Connection pooling:
http.Clientmanages underlying TCP connections via itsTransport. Reusing a client enables connection reuse and keep-alives, which drastically improves performance by avoiding repeated TCP/TLS handshakes.
-