diff --git a/ip_tool/hua_chen_client.go b/ip_tool/hua_chen_client.go index 46aaf5a..833568e 100644 --- a/ip_tool/hua_chen_client.go +++ b/ip_tool/hua_chen_client.go @@ -98,12 +98,13 @@ func (h *HuaChenIpClient) GetIpInfoFormCache(ctx context.Context, ip string, ttl if getCache != nil { return getCache, nil } - info, err := h.GetIpInfo(ip) + res, err = h.GetIpInfo(ip) if err != nil { return nil, errors.Wrapf(err, "获取ip:%s信息失败,", ip) } - infoJson, err := json.Marshal(info) + var infoJson []byte + infoJson, err = json.Marshal(res) if err != nil { return nil, errors.Wrapf(err, "无法将IP信息转换为JSON,ip:%s", ip) } @@ -112,7 +113,6 @@ func (h *HuaChenIpClient) GetIpInfoFormCache(ctx context.Context, ip string, ttl if err != nil { return nil, errors.Wrapf(err, "缓存ip:%s信息失败,", ip) } - res = info return }