鉴于这种类型type Response map[string]interface{}我创建了一个方法 NewResponse 来填充默认值: func NewResponse() Response { resp := Response{"status": 200, "msg": "Added jobs to queue"} resp_metadata := make(map[string]string) resp_metadata["base"] = "api/v1" resp_metadata["self"] = "/crawler/jobs/add" resp["metadata"] = resp_metadata return resp}我称之为 likeNewResponse()但我想改为这样做Response.New(),所以方法签名应该是这样的func (Response) New() Response {但后来我总是得到错误not enough arguments in call to Response.New。那么,如何实现呢?
- 3 回答
- 0 关注
- 259 浏览
添加回答
举报
0/150
提交
取消