dpvmjk0479 2017-06-23 18:14
浏览 98

转到错误拨号TCP:协议不可用

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))
}
  • 写回答

1条回答 默认 最新

  • duanjue2576 2018-09-17 11:21
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)