Day 40: New Package - net/netip
🥴 Mood: Hours of meetings.
🎵 Soundtrack: Reading Music
📚 Reading Github Issues
After hours of meetings in the morning, I read through the new github issues. This one about the net/netip package caught my eye. Why? Because it is a brand new net package for go 1.18!
⚙️ ipnet
Here is the issue Brad Fitz wrote proposing it. Here is his blog post on why he thinks go needs a better IP package.
Main points on why netip
is better than net.IP
and net.IPAddr
:
net.IP
is not comparablenet.IP
allocatesnet.IP
does not track if the original IP was ipv4 or ipv6.
Allllll the way back on day 1 I made my first contribution: adding examples for the ip functions. Today I went to see if this new ipnet package had any examples… nope! None!
As always, my favorite way to learn deeply about a new package is to try it out
for myself by writing examples for all of the functions. So that’s what I did.
Netip has a lot of similar functions as the previous packages (I assume it will
eventually replace net.IP
and net.IPAddr
), but it also has a lot more nice
helper functions like: Compare
, Less
, Next
, and Prev
.
There are lots of little functions, so I didn’t finish writing all of the examples today, but I plan to tomorrow.
When I was working on this, I spun up a local go pkgsite server so that I could
look at the docs via a browser and not my terminal. But I could not for the life
of me figure out how to make my local go pkgsite point to my local version of go
(rather than pulling down the latest version), despite the fact that there is a
flag for it! That I set! I eventually was able to hard code it to pull the
master
branch rather than the latest release, but that only shows the latest
committed netip
stuff, it does not show me my local changes. Note to self: ask
on gopher slack about this tomorrow!
📌 Other Updates
My go fuzz minimizing improvement was merged! 🎉