net/url: better handling or documentation of IPv6 addresses in url.URL.Host #61276
Labels
Documentation
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
What did you do?
https://go.dev/play/p/Lypv_o9VMRf
What did you expect to see?
https://[fc00::121:0:2:27]/some/path
What did you see instead?
https://fc00::121:0:2:27/some/path
This ends up being interpreted as
https://[fc00::121:0:2]:27/some/path
.The documentation for
url.URL.Host
ishost or host:port
, which leaves it unclear as to how a literal IPv6 address would be treated.I think it makes more sense to treat a literal IPv6 address as just that, and require the user to specify
[<ipv6-address>]:<port>
if that's what they actually wanted, though I appreciate that there would be backward compatibility issues with that.So at this point, it's probably best to just clarify the docs and add a reference to
net.JoinHostPort
. This could perhaps be done via #61093.The text was updated successfully, but these errors were encountered: