diff --git a/src/pkg/net/packetconn_test.go b/src/pkg/net/packetconn_test.go index 945003f67a..51f94acd8c 100644 --- a/src/pkg/net/packetconn_test.go +++ b/src/pkg/net/packetconn_test.go @@ -15,12 +15,6 @@ import ( "time" ) -func strfunc(s string) func() string { - return func() string { - return s - } -} - func packetConnTestData(t *testing.T, net string, i int) ([]byte, func()) { switch net { case "udp": @@ -62,12 +56,12 @@ func packetConnTestData(t *testing.T, net string, i int) ([]byte, func()) { var packetConnTests = []struct { net string - addr1 func() string - addr2 func() string + addr1 string + addr2 string }{ - {"udp", strfunc("127.0.0.1:0"), strfunc("127.0.0.1:0")}, - {"ip:icmp", strfunc("127.0.0.1"), strfunc("127.0.0.1")}, - {"unixgram", testUnixAddr, testUnixAddr}, + {"udp", "127.0.0.1:0", "127.0.0.1:0"}, + {"ip:icmp", "127.0.0.1", "127.0.0.1"}, + {"unixgram", testUnixAddr(), testUnixAddr()}, } func TestPacketConn(t *testing.T) { @@ -88,22 +82,21 @@ func TestPacketConn(t *testing.T) { continue } - addr1, addr2 := tt.addr1(), tt.addr2() - c1, err := ListenPacket(tt.net, addr1) + c1, err := ListenPacket(tt.net, tt.addr1) if err != nil { t.Fatalf("ListenPacket failed: %v", err) } - defer closer(c1, netstr[0], addr1, addr2) + defer closer(c1, netstr[0], tt.addr1, tt.addr2) c1.LocalAddr() c1.SetDeadline(time.Now().Add(100 * time.Millisecond)) c1.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) c1.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)) - c2, err := ListenPacket(tt.net, addr2) + c2, err := ListenPacket(tt.net, tt.addr2) if err != nil { t.Fatalf("ListenPacket failed: %v", err) } - defer closer(c2, netstr[0], addr1, addr2) + defer closer(c2, netstr[0], tt.addr1, tt.addr2) c2.LocalAddr() c2.SetDeadline(time.Now().Add(100 * time.Millisecond)) c2.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) @@ -145,12 +138,11 @@ func TestConnAndPacketConn(t *testing.T) { continue } - addr1, addr2 := tt.addr1(), tt.addr2() - c1, err := ListenPacket(tt.net, addr1) + c1, err := ListenPacket(tt.net, tt.addr1) if err != nil { t.Fatalf("ListenPacket failed: %v", err) } - defer closer(c1, netstr[0], addr1, addr2) + defer closer(c1, netstr[0], tt.addr1, tt.addr2) c1.LocalAddr() c1.SetDeadline(time.Now().Add(100 * time.Millisecond)) c1.SetReadDeadline(time.Now().Add(100 * time.Millisecond))