Yesterday Mikio Hara committed a new package for ipv4 handling to the go.net repository. I wanted to recognise Mikio’s work for two reasons.
- The level of detail and control this package offers is, in my opinion, unmatched by any other language. If you’re using C or C++, then you have the raw power of
setsockopt(2)
andioctl(2)
available, but you also have no guide or safety rail when using them. Mikio’s package provides exquisite control over ipv4 minutia without sacrificing the safety that Go provides. - The package is a fantastic example of using conditional compilation and embedding to build a very low level package that works across all the supported Go platforms. This package compiles cleanly on Linux, *BSD, OS X and Windows without resorting to the lowest common denominator or using a single
ifdef
. If you are looking for examples on how to structure your code using build tags, or looking for ways to work within the Go1 API, you should study this package.
Check it out for yourselves, go.pkgdoc.org/code.google.com/p/go.net/ipv4.