-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: ParseAddr gives different values with same input #50111
Comments
Expanded example a bit: https://go.dev/play/p/3uzuOmxzN1c?v=gotip |
And https://go.dev/play/p/owhCTtsY5Bn?v=gotip ... it stringifies without the zone, despite the |
Ah! The 4-in-6 special case to stringify it with the dotted quad form omits the zone check: func (ip Addr) String() string {
switch ip.z {
case z0:
return "invalid IP"
case z4:
return ip.string4()
default:
if ip.Is4In6() {
// TODO(bradfitz): this could alloc less.
return "::ffff:" + ip.Unmap().String()
}
return ip.string6()
}
} |
Change https://golang.org/cl/371094 mentions this issue: |
I assume this is |
Thanks, @capnspacehook! |
Weird, but don't drop the zone when stringifying. Fixes golang#50111 Change-Id: I5fbccdfedcdc77a77ee6bafc8d82b8ec8ec7220c Reviewed-on: https://go-review.googlesource.com/c/go/+/371094 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Matt Layher <[email protected]> Trust: Matt Layher <[email protected]> Trust: Ian Lance Taylor <[email protected]>
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
)?go env
OutputWhat did you do?
Tested that
netip.ParseAddr
would produce the same value twice when given the same input:https://go.dev/play/p/ZpqXiudtmA_P?v=gotip
What did you expect to see?
What did you see instead?
I found this bug and a few others while working on #49367.
The text was updated successfully, but these errors were encountered: