net/http的handle中启动goruntime

发布时间 2023-08-02 13:40:42作者: codestacklinuxer
{

http.HandleFunc("/device_status", radiusAccountHandler)

err := http.ListenAndServe(":8000", nil)

}

func radiusAccountHandler(w http.ResponseWriter, r *http.Request) {
    // 处理请求
    fmt.Fprintf(w, "ok")
    go sendAccountToInst(r)
}

实际上 执行sendAccountToInst函数时, 传入的参数r 值都为空。此时将go sendAccountToInst(r)改为 sendAccountToInst(r)就正常

什么原因?