1

When I tried to run GO code for rest api clint I got the error:

Get http://quotes.rest/qod.json: http: error connecting to proxy http://192.168.0.1:3128/: dial tcp 192.168.0.1:3128: i/o timeout

further I tried the same code in Go playground. There also error appeared.

What may be the reason? How can I solve this? Please help me to solve this issue.

The code I used is:-

package main

import(
    "net/http"
    "fmt"
    "io/ioutil"
)

func main() {

    resp, er := http.Get("http://quotes.rest/qod.json")
    if er!=nil{
            fmt.Println(er)
            return
        }
    defer resp.Body.Close()
    content, err := ioutil.ReadAll(resp.Body)
    if err!=nil{
            fmt.Println(err)
            return
        }
    fmt.Println(string(content))
}
2
  • 1
    Your client can't connect to the proxy, is your proxy working? Commented Jun 23, 2017 at 18:20
  • The proxy is also not working Commented Jul 12, 2017 at 17:46

1 Answer 1

3

The Go Playground does not allow HTTP requests. This has nothing to do with code. It is a security precaution enforced by the playground.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.