Golang net.ParseMAC() function and HardwareAddr type example

package net

Golang net.ParseMAC() function and HardwareAddr type usage example

 package main

 import (
 "fmt"
 "net"
 )

 func main() {

 hwAddr, err := net.ParseMAC("01:23:45:67:89:ab:cd:ef")

 if err != nil {
 fmt.Println(err)
 }

 fmt.Printf("Physical hardware address : %s \n", hwAddr.String())
 fmt.Printf("Physical hardware address : %#v \n", hwAddr)


 }

Sample output :

Physical hardware address : 01:23:45:67:89:ab:cd:ef

Physical hardware address : net.HardwareAddr{0x1, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}

References :

http://golang.org/pkg/net/#HardwareAddr

http://golang.org/pkg/net/#ParseMAC

Advertisement