Using TCP keepalive with Go
felixge.de
felixge.de
Edit: I'm saying this to clarify that I'm not recommending TCP keepalive for most scenarios.
What will happen to your connection if the network cable is plugged back in? Guess what, TCP will most likely recover and behave as if nothing happened. Keep in mind that opening a new connection is probably pretty expensive, especially if TLS is involved. So keep calm and let TCP do its magic.