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

Commit 10bc159

Browse files
committed
add IPPort.IsZero
1 parent 6509743 commit 10bc159

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

netaddr.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,11 @@ func ParseIPPort(s string) (IPPort, error) {
553553
return ipp, nil
554554
}
555555

556+
// IsZero reports whether IPPort is its zero value.
557+
func (p IPPort) IsZero() bool {
558+
return p.Port == 0 && p.IP.ipImpl == nil
559+
}
560+
556561
func (p IPPort) String() string {
557562
if v4, ok := p.IP.ipImpl.(v4Addr); ok {
558563
return fmt.Sprintf("%d.%d.%d.%d:%d", v4[0], v4[1], v4[2], v4[3], p.Port)

0 commit comments

Comments
 (0)