我有这个功能的问题:func execute(query Query) (goreq.Response, error) { res, err := goreq.Request{ Uri: "http://path/to/host", QueryString: query, Accept: "application/json", UserAgent: "XXXGoClient/1.0", Timeout: 2000 * time.Millisecond, Compression: goreq.Gzip(), //ShowDebug: true, }.Do() return *res, err}panic: runtime error: invalid memory address or nil pointer dereference当 http 请求出现错误时,我收到了。我知道我会检查这样的事情:if err != nil { // do somthing here}但我不知道我必须做什么,例如:if err != nil { return}我明白了 ./main.go:113: not enough arguments to return
- 3 回答
- 0 关注
- 242 浏览
添加回答
举报
0/150
提交
取消