refactor: get rid of router/utils.go

most functions end up in other files in the router package, but a few
land in common.
This commit is contained in:
Matthias Radestock committed 2015-11-07 15:45:29 +00:00
1 parent 7a5c910cd5
commit 8bd77c0d47
11 files changed
+114 -125

No files matched your search

+20
View File
@@ -11,6 +11,7 @@ import (
"fmt"
"io"
"net"
"os"
"sync"
"syscall"
"time"
@@ -1133,3 +1134,22 @@ func tickerChan(ticker *time.Ticker) <-chan time.Time {
}
return nil
}
func makeUDPAddr(addr *net.TCPAddr) *net.UDPAddr {
return &net.UDPAddr{IP: addr.IP, Port: addr.Port, Zone: addr.Zone}
}
// Look inside an error produced by the net package to get to the
// syscall.Errno at the root of the problem.
func PosixError(err error) error {
if operr, ok := err.(*net.OpError); ok {
err = operr.Err
}
// go1.5 wraps an Errno inside a SyscallError inside an OpError
if scerr, ok := err.(*os.SyscallError); ok {
err = scerr.Err
}
return err
}