Go语言中文网 为您找到相关结果 1

Golang http 超时设置方法

c := http.Client{ Transport: &http.Transport{ Dial: func(netw, addr string) (net.Conn, error) { deadline := time.Now().Add(25 * time.Second) c, err := net.DialTimeout(netw, addr, time.Second*20) if err != nil { return nil, err } c.SetDeadline(deadline) return c, nil }, }, } c.Get("http://www.qq.com") ////////////////////////////////////////////// /...阅读全文

博文 2015-02-28 09:31:57 nulijiabei