Golang net.IP.IsGlobalUnicast() function example
package net
Golang net.IP.IsGlobalUnicast() function example
package main
import (
"fmt"
"net"
)
func main() {
// google.com ip version 4 and 6 addresses
// from https://www.socketloop.com/tutorials/golang-resolve-domain-name-ip4-ip6
ip4 := "74.125.130.105"
// convert to IP type
ipAdd4 := net.ParseIP(ip4)
fmt.Println("Google.com ip4 address is a global unicast address : ", ipAdd4.IsGlobalUnicast())
}
Output :
Google.com ip4 address is a global unicast address : true
Reference :
Advertisement
Something interesting
Tutorials
+7.3k Golang : alternative to os.Exit() function
+12.2k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+13k Golang : Calculate elapsed years or months since a date
+13.2k Golang : Convert(cast) int to int64
+19.2k Golang : Delete item from slice based on index/key position
+13.9k Golang : Get dimension(width and height) of image file
+37.5k Upload multiple files with Go
+11.6k Golang : Display a text file line by line with line number example
+9.1k Golang : Handle sub domain with Gin
+10.7k Golang : Underscore string example
+6.7k Golang : Humanize and Titleize functions
+6.1k Golang : Missing Subversion command