Skip to content

Commit

Permalink
IsValid() seems to be useful
Browse files Browse the repository at this point in the history
  • Loading branch information
gaissmai committed Jul 27, 2022
1 parent fe71009 commit ddce6b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -24,6 +24,7 @@ type IPRange struct{ ... }

func (r IPRange) Addrs() (first, last netip.Addr)
func (r IPRange) String() string
func (r IPRange) IsValid() bool

func Merge(in []IPRange) (out []IPRange)
func (r IPRange) Remove(in []IPRange) (out []IPRange)
Expand Down
5 changes: 5 additions & 0 deletions iprange.go
Expand Up @@ -134,6 +134,11 @@ func FromNetipAddrs(first, last netip.Addr) (IPRange, error) {
return IPRange{first, last}, nil
}

// IsValid reports whether r is a valid IPRange.
func (r IPRange) IsValid() bool {
return r != zeroValue
}

// Addrs returns the first and last IP address of the IPRange.
func (r IPRange) Addrs() (first, last netip.Addr) {
return r.first, r.last
Expand Down

0 comments on commit ddce6b5

Please sign in to comment.