Hi Robert, Ian Lance Taylor said the exact opposite. "On Darwin I believe that by default we pass DNS lookups to the C library." (I assume "we" means Go developers.)
Are you correct or Ian is correct? On Tue, Feb 23, 2021 at 8:14 AM Robert Engels <[email protected]> wrote: > > As I pointed out, Go does not use the C library. > > > On Feb 23, 2021, at 7:57 AM, Peng Yu <[email protected]> wrote: > > > > This does not answer the question why net.Dial can not be made with > > the same behavior as ping on MacOSX. If the C library behaves > > differently on MacOSX and Linux, then the C library should not be > > relied on in this case. I just want to use /etc/hosts but not > > resolve.conf. > > > >> On 2/22/21, robert engels <[email protected]> wrote: > >> It looks like the Go runtime implements its own DNS client on *unix > >> platforms including OSX. > >> > >>>> On Feb 22, 2021, at 11:40 PM, Peng Yu <[email protected]> wrote: > >>> > >>> I don’t understand why ping does not have the same problem. Ping is not > >>> based on C library? > >>> > >>> On Mon, Feb 22, 2021 at 11:20 PM Ian Lance Taylor <[email protected] > >>> <mailto:[email protected]>> wrote: > >>> On Mon, Feb 22, 2021 at 9:11 PM Peng Yu <[email protected] > >>> <mailto:[email protected]>> wrote: > >>>> > >>>> I tried 1.16. > >>>> > >>>> $ go version > >>>> go version go1.16 darwin/amd64 > >>>> > >>>> The problem still exists. When I change mymachine.local to > >>>> mymachine_local, the problem is gone. So somehow, this is related to > >>>> host resolution? It might try to DNS lookup the hostname, when it can > >>>> not find it via DNS then it look up in /etc/hosts? > >>> > >>> On Darwin I believe that by default we pass DNS lookups to the C > >>> library. So I think that what you are seeing is the behavior of the C > >>> library. Try setting the environment variable GODEBUG=netdns=go. > >>> > >>> Ian > >>> > >>> > >>>> On 2/22/21, Ian Lance Taylor <[email protected] <mailto:[email protected]>> > >>>> wrote: > >>>>> On Mon, Feb 22, 2021 at 12:22 PM Peng Yu <[email protected] > >>>>> <mailto:[email protected]>> wrote: > >>>>>> > >>>>>> I run the following go program using net.Dial(). Depending on > >>>>>> whether > >>>>>> I specify a local hostname (defined in /etc/hosts) or an IP. I get > >>>>>> very different runtimes. > >>>>>> > >>>>>> But `ping mymachine.local` resolves the hostname to an IP address > >>>>>> instantaneously. So the two calls of the go program should have the > >>>>>> same runtimes. > >>>>>> > >>>>>> Can anybody reproduce the same runtime problem? Does anybody know > >>>>>> what > >>>>>> is wrong with the implementation of net.Dial()? Thanks. > >>>>>> > >>>>>> $ ./main mymachine.local:22 > >>>>>> 2021/02/22 14:14:25 before > >>>>>> 2021/02/22 14:14:30 after > >>>>>> $ ./main 192.168.1.104:22 <http://192.168.1.104:22/> > >>>>>> 2021/02/22 14:14:30 before > >>>>>> 2021/02/22 14:14:30 after > >>>>>> $ cat main.go > >>>>>> package main > >>>>>> import ( > >>>>>> "net" > >>>>>> "log" > >>>>>> "os" > >>>>>> ) > >>>>>> > >>>>>> func main() { > >>>>>> dialAddr := os.Args[1] > >>>>>> log.Println("before") > >>>>>> _, err := net.Dial("tcp", dialAddr) > >>>>>> log.Println("after") > >>>>>> if err != nil { > >>>>>> log.Fatalln(err) > >>>>>> } > >>>>>> } > >>>>> > >>>>> Which version of Go are you using? What operating system are you > >>>>> running > >>>>> on? > >>>>> > >>>>> It is possible that are running into https://golang.org/issue/35305 > >>>>> <https://golang.org/issue/35305>, > >>>>> which is fixed in 1.16. > >>>>> > >>>>> Ian > >>>>> > >>>> > >>>> > >>>> -- > >>>> Regards, > >>>> Peng > >>> -- > >>> Regards, > >>> Peng > >>> > >>> -- > >>> 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 [email protected] > >>> <mailto:[email protected]>. > >>> To view this discussion on the web visit > >>> https://groups.google.com/d/msgid/golang-nuts/CABrM6w%3D8Orgj3t4MW3%3DMs7L0vy0nFS_EeGjRZ8n%2BTvQOrHAO9g%40mail.gmail.com > >>> <https://groups.google.com/d/msgid/golang-nuts/CABrM6w%3D8Orgj3t4MW3%3DMs7L0vy0nFS_EeGjRZ8n%2BTvQOrHAO9g%40mail.gmail.com?utm_medium=email&utm_source=footer>. > >> > >> > > > > > > -- > > Regards, > > Peng > > > > -- > > 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 [email protected]. > > To view this discussion on the web visit > > https://groups.google.com/d/msgid/golang-nuts/CABrM6wkmMj7GgAckj6%3DcHZqd0vxnH0735%2BAc4n7zV%3D%3DBhD4Z8Q%40mail.gmail.com. > -- Regards, Peng -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CABrM6wnmuStmdsDOqioZ7jxL1jig6OE%2B%2BCn3hDJrJXQ6iqPA0A%40mail.gmail.com.
