Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

proposal: add Count() or Len() methods #218

Open
ortolot opened this issue Jan 17, 2022 · 0 comments
Open

proposal: add Count() or Len() methods #218

ortolot opened this issue Jan 17, 2022 · 0 comments

Comments

@ortolot
Copy link

ortolot commented Jan 17, 2022

Hello,

I think it would be useful to be able to get the number of IP addresses in ranges, prefixes and sets. That could take the form of Count() or Len() methods, I think.

For prefixes, the number of IP addresses would include all of them, including the min and max ones even if they could be a network and a broadcast address, as:

  • they are valid IP addresses,
  • tt is easy for the user to remove them from the count if needed,
  • including them makes it easier to add counts of multiple prefixes.

Right now, I think that, in order to count IP addresses in a range, I would have to convert its bounds into net.IPAddr and do arithmetics from there.

Regards,

--
Tanguy Ortolo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant