Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/netip: Add function Network() for netip Addr to make it support the interface of net.Addr #56264

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/net/netip/netip.go
Expand Up @@ -785,6 +785,9 @@ func (ip Addr) String() string {
}
}

// 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,
// to b and returns the extended buffer.
Expand Down Expand Up @@ -1144,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 @@ -1509,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" }