Ejemplo n.º 1
0
func TestJoinHostPort(t *testing.T) {
	result := "127.0.0.1:8000"

	if nets.JoinHostPort("127.0.0.1", "8000") != result {
		t.Fail()
	}

	if nets.JoinHostPort("127.0.0.1", 8000) != result {
		t.Fail()
	}

	if nets.JoinHostPort([]byte("127.0.0.1"), 8000) != result {
		t.Fail()
	}

	if nets.JoinHostPort([]byte("127.0.0.1"), "8000") != result {
		t.Fail()
	}
}
Ejemplo n.º 2
0
// DialTCP is the same as DialTCPWithAddr, but it joins host and port firstly.
func DialTCP(host, port interface{}) (*net.TCPConn, error) {
	addr := nets.JoinHostPort(host, port)
	return DialTCPWithAddr(addr)
}