猿问

使用http时使用delete函数删除地图条目

我需要删除地图中的条目。我尝试使用“删除”命令:


var actionResponseChannels = map[string]chan structs.ActionResponse{}

...

delete(actionResponseChannels, refID)

但我从 go 中得到一个错误:


不能在要删除的参数中使用 actionResponseChannels (type map[string]chan structs.ActionResponse) 作为类型 http.ResponseWriter: map[string]chan structs.ActionResponse 没有实现 http.ResponseWriter (缺少 Header 方法)go 不能使用 refID (type string ) 作为类型 *http.Request 在 deletego 的参数中


在我看来,删除与地图功能无关。


我正在使用 GO 版本 1.13.8 Linux/amd64。


有没有办法处理这个?谢谢。


狐的传说
浏览 118回答 1
1回答

慕标5832272

你的包中有一些 HTTP 处理函数delete,它会隐藏内置函数。重命名 HTTP 处理函数。
随时随地看视频慕课网APP

相关分类

Go
我要回答