Skip to Content [alt-c]


In reply to Comment by Andrew Ayer

Reader Ameya on 2020-06-27 at 20:44:

Unfortunately, Go provides no way to detect when a connection has been fully closed without trying to write at least one byte to it

Thank you! As a newcomer to Go, this problem drove me crazy. In Java, if I were running a select loop, I can just get an event that the remote end disconnected. I'm writing a HTTP (1.1) proxy for delivering webhooks in Go as a side project, and the way I "solve" this problem is by having an idle read timeout on the connection. Of course, this only works because it's HTTP, and the intended behavior of my proxy is to close the connection after a request-response interaction anyway.

I'm exploring possible solutions and plan to publish a blog post about it

Very much looking forward to it!


Post a Reply

Your comment will be public. To contact me privately, email me. Please keep your comment polite, on-topic, and comprehensible. Your comment may be held for moderation before being published.

(Optional; will be published)

(Optional; will not be published)

(Optional; will be published)

  • Blank lines separate paragraphs.
  • Lines starting with > are indented as block quotes.
  • Lines starting with two spaces are reproduced verbatim (good for code).
  • Text surrounded by *asterisks* is italicized.
  • Text surrounded by `back ticks` is monospaced.
  • URLs are turned into links.
  • Use the Preview button to check your formatting.