去错误拨号tcp:协议不可用

问题描述 投票:0回答:1

当我试图运行GO代码for rest api clint时,我得到了错误:

获取http://quotes.rest/qod.json:http:错误连接到代理http://192.168.0.1:3128/:拨打tcp 192.168.0.1:3128:i / o timeout

我在Go playground尝试了相同的代码。还出现了错误。

可能是什么原因?我怎么解决这个问题?请帮我解决这个问题。

我使用的代码是: -

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))
}
go tcp http-proxy
1个回答
0
投票

Go Playground不允许HTTP请求。这与代码无关。这是一个由操场强制执行的安全预防措施。

© www.soinside.com 2019 - 2024. All rights reserved.