golang/go

net: LookupHost shows different results between GODEBUG=netdns=cgo and go

Open

#22.902 aperta il 28 nov 2017

Vedi su GitHub
 (4 commenti) (0 reazioni) (0 assegnatari)Go (19.008 fork)batch import
NeedsFixhelp wanted

Metriche repository

Star
 (133.883 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

What version of Go are you using (go version)?

go version go1.9.2 darwin/amd64

What did you do?

package main

import (
	"net"
	"fmt"
)

func main() {
	fmt.Println(net.LookupHost("10.256"))
	fmt.Println(net.LookupHost("10.256.1"))
	fmt.Println(net.LookupHost("10.10.256"))
	fmt.Println(net.LookupHost("10.10.256.1"))
	fmt.Println(net.LookupHost("10.10.10.256"))
}

What did you expect to see?

This program works fine on both Linux & Windows and does show below output, but not on Mac

[] lookup 10.256: no such host
[] lookup 10.256.1: no such host
[] lookup 10.10.256: no such host
[] lookup 10.10.256.1: no such host
[] lookup 10.10.10.256: no such host

What did you see instead?

[10.0.1.0] <nil>
[] lookup 10.256.1: no such host
[10.10.1.0] <nil>
[] lookup 10.10.256.1: no such host
[] lookup 10.10.10.256: no such host

Guida contributor