net/http 在 Go Playground 中不起作用

net/http doesn't work in the Go Playground

谁能解释一下我做错了什么。所以基本上我正在尝试发出一个简单的 HTTP GET 请求。我从 https://gobyexample.com/http-clients. When I'm running it locally everything works fine, but in go playground https://play.golang.org/p/-28ykONUD98 复制了代码,它给出了:

panic: Get "http://gobyexample.com": dial tcp: lookup gobyexample.com on 169.254.169.254:53: dial udp 169.254.169.254:53: connect: no route to host

goroutine 1 [running]: main.main() /tmp/sandbox181131075/prog.go:13 +0x345

Program exited: status 2.

来自https://blog.golang.org/playground

Like the file system, the playground's network stack is an in-process fake implemented by the syscall package. It permits playground projects to use the loopback interface (127.0.0.1). Requests to other hosts will fail.

所以很正常,你的代码很好但是go playground只能连接到127.0.0.1