From 7e75d5f5ebbd374c2016ab454cba14294486f198 Mon Sep 17 00:00:00 2001 From: yuguojian <18126816215> Date: Thu, 17 Jul 2025 17:29:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=B0=E5=9D=80=E8=A7=A3?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gps_tool/an_na_qi_client.go | 6 +++--- gps_tool/response.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gps_tool/an_na_qi_client.go b/gps_tool/an_na_qi_client.go index 639a5ab..51d12de 100644 --- a/gps_tool/an_na_qi_client.go +++ b/gps_tool/an_na_qi_client.go @@ -88,7 +88,7 @@ func (n *AnNaQiGpsClient) GetGpsInfo(longitude, latitude float64) (res *AddressC return nil, errors.New(fmt.Sprintf("获取gps:%s信息失败,%+v", location, apiResult)) } -func (n *AnNaQiGpsClient) GetLocation(city, region, address string) (res *[]Geocode, err error) { +func (n *AnNaQiGpsClient) GetLocation(city, region, address string) (res []*Geocode, err error) { values := url.Values{} values.Set("city", city) values.Set("address", region+address) @@ -136,8 +136,8 @@ func (n *AnNaQiGpsClient) GetLocation(city, region, address string) (res *[]Geoc } // 检查API返回状态 if locationInfo.Code == 200 { - if len(locationInfo.Data.Geocodes) > 0 { - return &locationInfo.Data.Geocodes, nil + if locationInfo.Data.Count > 0 { + return locationInfo.Data.Geocodes, nil } } diff --git a/gps_tool/response.go b/gps_tool/response.go index b0cb061..1150bfe 100644 --- a/gps_tool/response.go +++ b/gps_tool/response.go @@ -64,8 +64,8 @@ type LocationInfo struct { } type LocationDatum struct { - Count int `json:"count"` - Geocodes []Geocode `json:"geocodes"` + Count int `json:"count"` + Geocodes []*Geocode `json:"geocodes"` } type Geocode struct {