Hacker News new | ask | show | jobs
by acln 3777 days ago
Under certain conditions, it does not.

https://golang.org/pkg/net/#hdr-Name_Resolution

1 comments

When it does not it dynamically links.
That does not make sense.

Among others the page lists:

> [...] when /etc/resolv.conf or /etc/nsswitch.conf specify the use of features that the Go resolver does not implement, and when the name being looked up ends in .local or is an mDNS name.

Those things you can't check at compile time.

In any case, you can tell whether the binary is statically linked or not.

Statically linked:

    $ file /usr/bin/consul 
    /usr/bin/consul: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
    $ ldd /usr/bin/consul
            not a dynamic executable
Dynamically linked:

    $ file /bin/echo
    /bin/echo: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
    $ ldd /bin/echo
            linux-vdso.so.1 =>  (0x00007fff01fff000)
            libc.so.6 => /lib64/libc.so.6 (0x0000003bcd800000)
            /lib64/ld-linux-x86-64.so.2 (0x0000003bcd000000)
Notice the libc.so.6