What version of Go are you using (go version)?
$ go version
go1.10 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What did you do?
I'm trying to unmarshal json content into net.IP and net.HardwareAddr.
Both types are actually of type []byte
Since net.IP implements json.Marshaler, it works as expected. However, net.HardwareAddr does not and fails with the error "illegal base64 data at input byte 2" (that's the position of the separator).
Here's an example:
https://play.golang.org/p/HOBBAyvpfrK
I found the google group discussion about adding the Marshaller to the net.IP type: https://groups.google.com/forum/#!topic/golang-nuts/io8aHJarm6U
What did you expect to see?
I expect net.HardwareAddr to be consistent with net.IP and implement json.Marshaler.
Strings in the form of "ab:cd:ef:ab:cd:ef" inside json should be parsable to MAC addresses.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes.
What did you do?
I'm trying to unmarshal json content into
net.IPandnet.HardwareAddr.Both types are actually of type
[]byteSince
net.IPimplementsjson.Marshaler, it works as expected. However, net.HardwareAddr does not and fails with the error "illegal base64 data at input byte 2" (that's the position of the separator).Here's an example:
https://play.golang.org/p/HOBBAyvpfrK
I found the google group discussion about adding the Marshaller to the
net.IPtype: https://groups.google.com/forum/#!topic/golang-nuts/io8aHJarm6UWhat did you expect to see?
I expect
net.HardwareAddrto be consistent withnet.IPand implementjson.Marshaler.Strings in the form of
"ab:cd:ef:ab:cd:ef"inside json should be parsable to MAC addresses.