even shorter

This commit is contained in:
Miek Gieben 2014-07-09 21:06:42 +01:00
parent d161b9087e
commit 20ddea5ac9
1 changed files with 2 additions and 4 deletions

View File

@ -23,8 +23,7 @@ import (
func setUDPSocketOptions4(conn *net.UDPConn) error {
// We got the .File() in NewUDPConn, this this will work.
file, _ := conn.File()
err := syscall.SetsockoptInt(int(file.Fd()), syscall.IPPROTO_IP, syscall.IP_PKTINFO, 1)
if err != nil {
if err := syscall.SetsockoptInt(int(file.Fd()), syscall.IPPROTO_IP, syscall.IP_PKTINFO, 1); err != nil {
return err
}
return nil
@ -34,8 +33,7 @@ func setUDPSocketOptions4(conn *net.UDPConn) error {
func setUDPSocketOptions6(conn *net.UDPConn) error {
// We got the .File() in NewUDPConn, this this will work.
file, _ := conn.File()
err := syscall.SetsockoptInt(int(file.Fd()), syscall.IPPROTO_IPV6, syscall.IPV6_RECVPKTINFO, 1)
if err != nil {
if err := syscall.SetsockoptInt(int(file.Fd()), syscall.IPPROTO_IPV6, syscall.IPV6_RECVPKTINFO, 1); err != nil {
return err
}
return nil