On Fri, Oct 24, 2014 at 9:20 AM, Shawn Milochik <
sh...@milochik.com> wrote:
> On Fri, Oct 24, 2014 at 12:13 PM, Harmen B <
har...@typetypetype.net> wrote:
>>
>>
>> This old post explains the non-static-ness:
>>
>> "By default, even programs that are pure Go do link aginst libc if they
>> do any DNS lookups or user name lookups. This is because those
>> operations are highly system-dependent to deal with things like
>> firewalls and LDAP. "
>>
>>
https://groups.google.com/d/topic/golang-nuts/4Q4HLHRcHQY/discussion
>>
>
> Thanks, that's interesting. So it's only stuff in the "net" package. At
> least according to that thread.
Also the os/user package.
> Based on the thread you sent, I see that this works also:
>
> go build -tags netgo -a -o listen listen.go
>
>
> (Use -tags -netgo instead of the CGO environment variable). Either case
> still requires -a.
>
> So if it works just fine without a dependency, and it's available to
> override and fall back on, why isn't that the default?
Because it doesn't work just fine. On Darwin systems it fails to work
through the default firewall. On GNU/Linux systems it ignores
/etc/nsswitch.conf. On all systems it ignores some of the more
esoteric functionality available in /etc/resolv.conf. Implementing
all the system-specific stuff that the libc resolver uses is a red
queen's race, and may not be possible at all on Darwin.
The thinking is that for the ordinary user, it's better if Go programs
behave like other programs on the system with regard to the complex
details of DNS lookup and username lookup. As you've discovered,
other options are available for the advanced user.
Ian