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: CGO_ENABLED=1 but go build -tags netgo doesn't enable netgo resolver #6582
Labels
Milestone
Comments
> are you suggesting that setting netgo build tag won't enable the Go DNS resolver? Yup. > but the code could resolve DNS names, See net/lookup_unix.go. func lookupIP(host string) (addrs []IP, err error) { addrs, err, ok := cgoLookupIP(host) if !ok { addrs, err = goLookupIP(host) } return } > and the binary is indeed statically linked, It doesn't matter in this case. > so i'm not sure what's the problem. Hm, probably I'm wrong. Please try to build and run "CGO_ENABLED=1 && -tags netgo" image. Hope syscall trace tool will show something something. |
> Hope syscall trace tool will show something something. If you see the image does some IP-layer reachability tests to the records in query response messages, that might be the signature of more powerful external DNS resolver because our netgo resolver doesn't implement such kind of feature so far. |
i write a simple program, and use -tag netgo to build it, it can resolve www.google.com and strace(1) verifies that it did connect to 8.8.8.8 to resolve the DNS. the most important thing is: it is statically linked, so it couldn't possibly use the cgo lookup code (which by definition means the binary must be dynamically linked to use libc) and I also verified with ltrace(1) that if i remove the netgo build tag, and rebuild the stdlib and the program, it will call getaddrinfo(3). |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: