我有一个像这样的 Go 代码
func (r *Request) SetRequestMap(ctx *gin.Context, data map[string]interface{}) *Request {
//Some processing code
id, ok := r.map["id"]
if !ok {
return r
}
checkStatus := checkStatusOnline(ctx, id) // checkStatusOnline returns "on" if id is present or "off".
// It make use of HTTP GET request internally to check if id is present or not.
// All json unmarshal is taken care of internally
if checkStatus == "on" {
r.map["val"] = "online"
}
return r
}
我想为SetRequestMap
.
如何在checkStatusOnline
不为模拟实现任何额外功能的情况下模拟?