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.ParseIP doesn't expand IPv4 addresses #36828

Closed
perpetual-hydrofoil opened this issue Jan 28, 2020 · 1 comment
Closed

net.ParseIP doesn't expand IPv4 addresses #36828

perpetual-hydrofoil opened this issue Jan 28, 2020 · 1 comment

Comments

@perpetual-hydrofoil
Copy link

perpetual-hydrofoil commented Jan 28, 2020

package main

import (
    "fmt"
    "net"
)

func main() {
    ip := net.ParseIP("1.1") // this is nil
    if ip.To4() == nil {
        fmt.Printf("%v is not an IPv4 address", ip)
    }
}

See #36822 (comment) for more discussion.

It appears to be part of the POSIX specification, but not part of an RFC, but it still has a lot of uses (ping 127.1, https://1.1, etc) and is generally available in POSIX operating systems.

http://man7.org/linux/man-pages/man3/inet_addr.3.html

net being unable to expand IPv4's may also be the root cause behind #36822.

@ianlancetaylor
Copy link
Contributor

I don't think we need two issues for this. Closing in favor of #36822. Please comment if you disagree.

@golang golang locked and limited conversation to collaborators Jan 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants