Golang net.IP.IsLoopback(), IsMulticast() and IsUnspecified() functions example
package net
Golang net.IP.IsLoopback(), IsMulticast() and IsUnspecified() functions usage example
package main
import (
"fmt"
"net"
)
func main() {
ip4 := "127.0.0.1"
// convert to IP type
ipAdd4 := net.ParseIP(ip4)
fmt.Println("127.0.0.1 is a loopback address: ", ipAdd4.IsLoopback())
fmt.Println("127.0.0.1 is a multicast address : ", ipAdd4.IsMulticast())
fmt.Println("127.0.0.1 is an unspecfied address : ", ipAdd4.IsUnspecified())
}
Output :
127.0.0.1 is a loopback address: true
127.0.0.1 is a multicast address : false
127.0.0.1 is an unspecfied address : false
References :
http://golang.org/pkg/net/#IP.IsLoopback
Advertisement
Something interesting
Tutorials
+16k Golang : Get file permission
+22.8k Golang : Strings to lowercase and uppercase example
+20.3k Golang : Count number of digits from given integer value
+36.4k Golang : Convert(cast) int64 to string
+5.8k Get website traffic ranking with Similar Web or Alexa
+5.5k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+81.9k Golang : How to return HTTP status code?
+7.2k Golang : Gorrila mux.Vars() function example
+13.2k Golang : Convert(cast) uintptr to string example
+8.3k Golang : Find relative luminance or color brightness
+5.5k Unix/Linux/MacOSx : How to remove an environment variable ?
+20.7k Nginx + FastCGI + Go Setup.