aboutsummaryrefslogtreecommitdiff
path: root/src/net/error_test.go
diff options
context:
space:
mode:
authorMikio Hara <mikioh.mikioh@gmail.com>2015-04-21 22:53:47 +0900
committerMikio Hara <mikioh.mikioh@gmail.com>2015-04-29 22:37:30 +0000
commitafd2d2b6df3ebfe99faf347030f15adfdf422fa0 (patch)
tree11d358f251d08cdbd489a6515cffa374167564e2 /src/net/error_test.go
parent35748919429c23b9ea91099b8d3b481dff5bbae5 (diff)
downloadgo-afd2d2b6df3ebfe99faf347030f15adfdf422fa0.tar.xz
net: add Source field to OpError
Not only by network, transport-layer intermediaries but by virtualization stuff in a node, it is hard to identify the root cause of weird faults without information of packet flows after disaster happened. This change adds Source field to OpError to be able to represent a 5-tuple of internet transport protocols for helping dealing with complicated systems. Also clarifies the usage of Source and Addr fields. Updates #4856. Change-Id: I96a523fe391ed14406bfb21604c461d4aac2fa19 Reviewed-on: https://go-review.googlesource.com/9231 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/net/error_test.go')
-rw-r--r--src/net/error_test.go35
1 files changed, 7 insertions, 28 deletions
diff --git a/src/net/error_test.go b/src/net/error_test.go
index 03c646c7c9..75b125d435 100644
--- a/src/net/error_test.go
+++ b/src/net/error_test.go
@@ -32,34 +32,13 @@ func (e *OpError) isValid() error {
if e.Net == "" {
return fmt.Errorf("OpError.Net is empty: %v", e)
}
- switch addr := e.Addr.(type) {
- case *TCPAddr:
- if addr == nil {
- return fmt.Errorf("OpError.Addr is empty: %v", e)
- }
- case *UDPAddr:
- if addr == nil {
- return fmt.Errorf("OpError.Addr is empty: %v", e)
- }
- case *IPAddr:
- if addr == nil {
- return fmt.Errorf("OpError.Addr is empty: %v", e)
- }
- case *IPNet:
- if addr == nil {
- return fmt.Errorf("OpError.Addr is empty: %v", e)
- }
- case *UnixAddr:
- if addr == nil {
- return fmt.Errorf("OpError.Addr is empty: %v", e)
- }
- case *pipeAddr:
- if addr == nil {
- return fmt.Errorf("OpError.Addr is empty: %v", e)
- }
- case fileAddr:
- if addr == "" {
- return fmt.Errorf("OpError.Addr is empty: %v", e)
+ for _, addr := range []Addr{e.Source, e.Addr} {
+ if addr != nil {
+ switch addr.(type) {
+ case *TCPAddr, *UDPAddr, *IPAddr, *IPNet, *UnixAddr, *pipeAddr, fileAddr:
+ default:
+ return fmt.Errorf("OpError.Source or Addr is unknown type: %T, %v", addr, e)
+ }
}
}
if e.Err == nil {