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

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

Description

@ortolot

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions