net:http 包禁用死锁检测

10 min read

导入 net 包启动后台轮询 Goroutines,有效禁用死锁检测器。

相关讨论: https://github.com/golang/go/issues/12734

package main

import (
 "fmt"
 "net/http"
 "time"
)

func main() {
 c := make(chan string)
 fmt.Println("Starting the server")
    client := http.Client{Timeout: time.Duration(1) * time.Second}
 fmt.Println("Starting the client")
 c <- "http://www.baidu.com"
 fmt.Println("c")
    fmt.Printf("client : %T", client)
}