2019-03-01 10:54:19 +01:00
|
|
|
package data
|
|
|
|
|
|
|
|
import "net"
|
|
|
|
|
2019-03-08 15:53:45 +01:00
|
|
|
type HardwareAddr net.HardwareAddr
|
|
|
|
|
|
|
|
//MarshalJSON to bytearray
|
|
|
|
func (a HardwareAddr) String() string {
|
|
|
|
return net.HardwareAddr(a).String()
|
|
|
|
}
|
2019-03-01 10:54:19 +01:00
|
|
|
|
|
|
|
//MarshalJSON to bytearray
|
|
|
|
func (a HardwareAddr) MarshalText() ([]byte, error) {
|
|
|
|
return []byte(a.String()), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON from bytearray
|
2019-03-08 15:53:45 +01:00
|
|
|
func (a HardwareAddr) UnmarshalText(data []byte) error {
|
|
|
|
b, err := net.ParseMAC(string(data))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
a = HardwareAddr(b)
|
|
|
|
return nil
|
2019-03-01 10:54:19 +01:00
|
|
|
}
|