net.ParseIP unable to parse some types of ipv6 addresses

62 views
Skip to first unread message

andrey mirtchovski

unread,
May 1, 2020, 12:25:55 PM5/1/20
to golang-nuts
IPv6 addresses including a zone identifier [rfc4007] are not parsed
correctly by net.ParseIP. is there any point in creating an issue or
is this intentional and we're supposed to strip the zone identifier?

https://play.golang.org/p/kQKyYYnZydX

Brian Candler

unread,
May 1, 2020, 1:15:51 PM5/1/20
to golang-nuts
parseIP returns a net.IP which is just a slice of bytes without the zone.

However, type net.IPAddr includes the zone.  Looks like net.ResolveIPAddr will do the job:


andrey mirtchovski

unread,
May 1, 2020, 1:28:04 PM5/1/20
to Brian Candler, golang-nuts
thanks. that ought to do it.
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/0168d004-5c54-4430-8c09-1a8a8d7ea736%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages