THRIFT-5509: Close connection in IsOpen

Client: go

When the connectivity check failed in IsOpen, close the connection
explicitly to avoid connection leaks.

This is Path 2 of THRIFT-5509.
diff --git a/lib/go/thrift/socket_conn.go b/lib/go/thrift/socket_conn.go
index 5619d96..bbb5b7d 100644
--- a/lib/go/thrift/socket_conn.go
+++ b/lib/go/thrift/socket_conn.go
@@ -20,6 +20,7 @@
 package thrift
 
 import (
+	"errors"
 	"net"
 	"sync/atomic"
 )
@@ -83,7 +84,17 @@
 	if !sc.isValid() {
 		return false
 	}
-	return sc.checkConn() == nil
+	if err := sc.checkConn(); err != nil {
+		if !errors.Is(err, net.ErrClosed) {
+			// The connectivity check failed and the error is not
+			// that the connection is already closed, we need to
+			// close the connection explicitly here to avoid
+			// connection leaks.
+			sc.Close()
+		}
+		return false
+	}
+	return true
 }
 
 // Read implements io.Reader.