-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Closed
Copy link
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.OS-Windows
Milestone
Description
What version of Go are you using (go version
)?
$ go version go version go1.19.5 windows/amd64 go version go1.20rc2 windows/amd64
What did you do?
Set Windows system DNS to a standard server which doesn't resolve localhost
, then use Go net package to resolve a domain defined in local hosts
file (C:\Windows\System32\Drivers\etc\hosts
).
package main
import (
"fmt"
"net"
)
func main() {
addr, err := net.ResolveTCPAddr("tcp", "localhost:12345")
fmt.Printf("addr=%v, err=%v\n", addr, err)
}
What did you expect to see?
Go should respect C:\Windows\System32\Drivers\etc\hosts
file and resolve localhost
correctly with -tags=netgo
.
What did you see instead?
Go can not resolve localhost with -tags=netgo
C:\work> go run resolvtest.go
addr=127.0.0.1:12345, err=<nil>
C:\work> go run -tags=netgo resolvtest.go
addr=<nil>, err=lookup localhost on 8.8.8.8:53: no such host
AgustinRamiroDiaz
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.OS-Windows