Skip to content

Commit 5fe2216

Browse files
committed
core/closer: deep nil checks for interfaces
1 parent b0e2829 commit 5fe2216

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

intra/core/closer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func CloseTCP(c *net.TCPConn) {
5050

5151
// CloseTCPRead closes the read end of r.
5252
func CloseTCPRead(r TCPConn) {
53-
if r != nil {
53+
if r != nil && IsNotNil(r) {
5454
// avoid expensive reflection:
5555
// groups.google.com/g/golang-nuts/c/wnH302gBa4I
5656
switch x := r.(type) {
@@ -72,7 +72,7 @@ func CloseTCPRead(r TCPConn) {
7272

7373
// CloseTCPWrite closes the write end of w.
7474
func CloseTCPWrite(w TCPConn) {
75-
if w != nil {
75+
if w != nil && IsNotNil(w) {
7676
switch x := w.(type) {
7777
case *net.TCPConn:
7878
if x != nil {
@@ -93,7 +93,7 @@ func CloseTCPWrite(w TCPConn) {
9393
// CloseConn closes cs.
9494
func CloseConn(cs ...MinConn) {
9595
for _, c := range cs {
96-
if c == nil {
96+
if c == nil || IsNil(c) {
9797
continue
9898
}
9999
switch x := c.(type) {
@@ -130,7 +130,7 @@ func Close(cs ...io.Closer) {
130130

131131
// CloseOp closes op on c.
132132
func CloseOp(c io.Closer, op CloserOp) {
133-
if c == nil {
133+
if c == nil || IsNil(c) {
134134
return
135135
}
136136
switch x := c.(type) {

0 commit comments

Comments
 (0)