3 ms·
from the article: > The underlying type of a net.IP is just a []byte > ... > It’s large. A Go slice is 3 words (so 24 bytes total on 64-bit machines) just fo
by evil-olive 6y ago
from the article:
> The underlying type of a net.IP is just a []byte
> ...
> It’s large. A Go slice is 3 words (so 24 bytes total on 64-bit machines) just for the slice header, without counting the underlying array that the slice points to (background). So an IP address with Go’s net.IP is two parts: the 24 byte slice header, and then also the 4 or 16 bytes of IP address. If you want an IPv6 zone, you have to use net.IPAddr with a 16 byte string header also.
- boring_twenties 6y agoThanks, that's a bit interesting. I only know a little bit of Go, but I would have assumed you could just use an array ([4]byte) directly without a slice ([]byte) on top of it. Guess not.