Using DumpResponse can Lead to Unclosed Response Bodies
On the surface httputil.DumpResponse(resp *http.Response, body bool) ([]byte, error) seems like a very simple function that serializes a http.Response into a []byte. However, using this function correctly is harder than it seems. In fact, even the standard library’s example has a subtle bug that stems from using httputil.DumpResponse(). Let’s take a look at the example in question:
TLS Handshake Timeouts in Go
I recently came across a situation where a Go program (built with go1.8.3) had spawned a lot more goroutines than required. Profiling revealed the cause to be go routines blocked on reading from a client while negotiating the TLS handshake. The goroutine stack trace led me to the following code segment in crypto/tls:
Introducing the Uerrors Package
Internal error messages are usually brief and in a format that is optimized for logging and searching. An example would be: > error=true, service=phantom, txid=12345, msg="user not authorized" While that’s a great error message for developers to search by tags, its not a great error message to display to an end user.