net: ParseCIDR returns IP of size 16 and not 4 for IPv4 #38097
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Fedora 31
What did you do?
ParseCIDR does not return IP of expected size, at least according to the contract https://golang.org/pkg/net/#IP.To16 where it reads "If ip is not an IP address (it is the wrong length), To16 returns nil." Although the implementation of the IP address should be hidden, functions To4 and To16 actually do not follow the documentation. I want to use them to determine if the parsed IP address is IPv4 or IPv6, looks like it can't be done in any other way.
Reproducer: https://play.golang.org/p/eEiQOZkOWnu
The text was updated successfully, but these errors were encountered: