I have two network interfaces on my computer ( eth0 and eth1) and I\'m trying to Dial a connection using a specific one (eth1). Given the statement that Go is a system langu
When you pull the address from an interface, it's of type *net.IPnet
wrapped in a net.Addr
interface, which contains and address and netmask not an address and port. You can use the IP address however to create a new TCPAddr after asserting it as a *net.IPnet
ief, err := net.InterfaceByName("eth1")
if err !=nil{
log.Fatal(err)
}
addrs, err := ief.Addrs()
if err !=nil{
log.Fatal(err)
}
tcpAddr := &net.TCPAddr{
IP: addrs[0].(*net.IPNet).IP,
}