Re:Rust: 128 bit integers preparing to be released
by LeonidBugaev on Sunday December 04, 2016 @03:06AM
(#13099241)
If you are using default library IPv4 addresses stores as [16]byte: https://golang.org/src/net/ip.go
[ Parent
| on HN ]
Re:Rust: 128 bit integers preparing to be released
by daenney on Sunday December 04, 2016 @04:50AM
(#13099428)
I don't think that's what the Godoc says. The IP type is defined as []byte
type IP []byte
That is not the same as [16]byte. // Note that in this documentation, referring to an
// IP address as an IPv4 address or an IPv6 address
// is a semantic property of the address, not just the
// length of the byte slice: a 16-byte slice can still
// be an IPv4 address.
What I believe that comment is saying is that something that is [16]byte can still be an IPv4 address, but that doesn't mean that all IPv4 addresses are stored as [16]byte. At least that would be my interpretation based on the comment above it: // An IP is a single IP address, a slice of bytes.
// Functions in this package accept either 4-byte (IPv4)
// or 16-byte (IPv6) slices as input.