Skip to content

Commit 55bc2f8

Browse files
fix panic (#69)
如果: ``` Error *Error `json:"error"` ``` 而服务器没有返回 error 字段,会在执行: ``` if resp.Error.Code > 0 { ``` 时报错: ``` panic: runtime error: invalid memory address or nil pointer dereference ```
1 parent 1e2aa3f commit 55bc2f8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

address.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func ReadAddress(ctx context.Context, addressId, uid, sid, sessionKey string) (*
7878

7979
var resp struct {
8080
Data *Address `json:"data"`
81-
Error *Error `json:"error"`
81+
Error Error `json:"error"`
8282
}
8383
err = json.Unmarshal(body, &resp)
8484
if err != nil {

0 commit comments

Comments
 (0)