1
0
mirror of https://github.com/golang/go synced 2024-11-13 17:20:22 -07:00

net: panic if sockaddrToTCP returns nil incorrectly

Part of diagnosing the selfConnect bug
TBR=dsymonds

R=golang-dev
CC=golang-dev
https://golang.org/cl/5687057
This commit is contained in:
Rob Pike 2012-02-21 15:21:34 +11:00
parent 2155a0408e
commit 3970d2fd58

View File

@ -9,6 +9,7 @@
package net
import (
"fmt"
"io"
"os"
"syscall"
@ -26,6 +27,12 @@ func sockaddrToTCP(sa syscall.Sockaddr) Addr {
return &TCPAddr{sa.Addr[0:], sa.Port}
case *syscall.SockaddrInet6:
return &TCPAddr{sa.Addr[0:], sa.Port}
default:
if sa != nil {
// TODO(r): Diagnose when we will turn a non-nil sockaddr into a nil.
// Part of diagnosing the selfConnect bug.
panic(fmt.Sprintf("unexpected type in sockaddrToTCP: %T", sa))
}
}
return nil
}