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: LookupAddr adds trailing dots to entries from /etc/hosts #13564

rsc opened this issue Dec 10, 2015 · 2 comments

net: LookupAddr adds trailing dots to entries from /etc/hosts #13564

rsc opened this issue Dec 10, 2015 · 2 comments


Copy link

@rsc rsc commented Dec 10, 2015

Here is a program:

package main

import (

func main() {

When run, it prints:

$ go run /tmp/x.go
[localhost.] <nil>

This is incorrect, given this /etc/hosts:

$ cat /etc/hosts
# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##   localhost broadcasthost
::1             localhost 

Names obtained from the DNS system are rooted and have a trailing dot. Names obtained from /etc/hosts should not.

This is a partial regression from Go 1.5 and should be fixed for Go 1.6.

It looks like Go 1.5 was inconsistent based on what routines were being used:

$ GODEBUG=netdns=go go1.5 run /tmp/x.go
[localhost] <nil>
$ GODEBUG=netdns=cgo go1.5 run /tmp/x.go
[localhost.] <nil>

and now netdns=go has been changed to match netdns=cgo:

$ GODEBUG=netdns=go go run /tmp/x.go
[localhost.] <nil>
$ GODEBUG=netdns=cgo go run /tmp/x.go
[localhost.] <nil>

I'm not sure that's the right fix.

@rsc rsc added this to the Go1.6 milestone Dec 10, 2015
Copy link

@gopherbot gopherbot commented Jan 7, 2016

CL mentions this issue.

@rsc rsc closed this in 6b9298a Jan 8, 2016
Copy link

@gopherbot gopherbot commented Jan 13, 2016

CL mentions this issue.

gopherbot pushed a commit that referenced this issue Jan 13, 2016
…9 and Windows

This change applies the fix for #13564 to Plan 9 and Windows.
Also enables Lookup API test cases on builders.

Updates #13564.

Change-Id: I863f03c7cb6fbe58b3a55223bfa0ac5f9bf9c3df
Run-TryBot: Mikio Hara <>
TryBot-Result: Gobot Gobot <>
Reviewed-by: Russ Cox <>
@golang golang locked and limited conversation to collaborators Jan 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants