Golang net.DialIP() function example
package net
Golang net.DialIP() function usage example
package main
import (
"fmt"
"net"
)
func main() {
// replace x with your target IP address
raddr := &net.IPAddr{IP: net.IPv4(x, x, x, x).To4()}
laddr := &net.IPAddr{IP: net.IPv4(x, x, x, x)}
ipconn, err := net.DialIP("ip:tcp", laddr, raddr)
if err != nil {
fmt.Println("Error: ", err)
} else {
fmt.Println(ipconn)
}
}
References :
Advertisement
Something interesting
Tutorials
+36.5k Golang : Validate IP address
+10k Golang : Channels and buffered channels examples
+9.1k Golang : Get curl -I or head data from URL example
+7.2k Golang : Null and nil value
+14.5k Golang : How to determine if user agent is a mobile device example
+5.6k PHP : Convert string to timestamp or datestamp before storing to database(MariaDB/MySQL)
+5.3k Golang : How to deal with configuration data?
+32.7k Golang : Regular Expression for alphanumeric and underscore
+15.9k Golang : Update database with GORM example
+14.6k Golang : How to get URL port?
+18.6k Golang : Find IP address from string