Skip to content

Commit

Permalink
implement the interface of net.Addr
Browse files Browse the repository at this point in the history
  • Loading branch information
zhlsunshine committed Nov 2, 2022
1 parent c44e65b commit 3e8f899
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/net/netip/netip.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,8 @@ func (ip Addr) String() string {
}
}

// Network returns the address's network name, "addr.hi+addr.lo+ip-family-zone".
func (ip Addr) Network() string { return "ip.hi+ip.lo+ip-family-zone" }
// Network returns the address's network name, "hi+lo+ipzone".
func (ip Addr) Network() string { return "hi+lo+ipzone" }

// AppendTo appends a text encoding of ip,
// as generated by MarshalText,
Expand Down Expand Up @@ -1147,6 +1147,9 @@ func (p AddrPort) String() string {
}
}

// Network returns the AddrPort's network name, "ip+port".
func (p AddrPort) Network() string { return "ip+port" }

func joinHostPort(host, port string) string {
// We assume that host is a literal IPv6 address if host has
// colons.
Expand Down Expand Up @@ -1512,3 +1515,6 @@ func (p Prefix) String() string {
}
return p.ip.String() + "/" + itoa.Itoa(int(p.bits))
}

// Network returns the Prefix's network name, "ip+bits".
func (p Prefix) Network() string { return "ip+bits" }

0 comments on commit 3e8f899

Please sign in to comment.