phaag / go-nfdump

go-nfdump: A Go module to read and process nfdump files
BSD 2-Clause "Simplified" License
7 stars 1 forks source link

Viability to use netip.Addr instead of net.IP #5

Closed gabrielmocan closed 1 year ago

gabrielmocan commented 1 year ago

Pete, I was wondering if we can use netip.Addr type instead of net.IP type for representing IPs.

Advantages are: we keep the same functionalities of net.IP plus:

"Compared to the net.IP type, this package's Addr type takes less memory, is immutable, and is comparable (supports == and being a map key)."

https://pkg.go.dev/net/netip

This will enable using the addresses as map keys, which is very useful for filtering and aggregations.

gabrielmocan commented 1 year ago

Peter, I'm sorry for opening this issue, but in hindsight it's better to keep net.IP as default representation, as most libs and methods available in Go [e.g mmdbLookup()] uses net.IP as input type. I'm closing this issue.