Can someone please explain what am I doing wrong. So basically I'am trying to make a simple HTTP GET
request. I copied code from https://gobyexample.com/http-clients. When I'm running it locally everything works fine, but in go playground https://play.golang.org/p/-28ykONUD98 it gives:
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.
From 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.
So it's normal, your code is good but go playground can only connect to 127.0.0.1