Skip to content

Commit a9e5bb7

Browse files
committed
update
1 parent de53017 commit a9e5bb7

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

city.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ type CityInfo struct {
3232

3333
Line string `json:"line"`
3434

35-
DistrictName string `json:"district_name"`
36-
Radius string `json:"radius"`
35+
DistrictInfo DistrictInfo `json:"district_info"`
3736

3837
Route string `json:"route"`
3938
ASN string `json:"asn"`
@@ -117,6 +116,9 @@ func (db *City) FindInfo(addr, language string) (*CityInfo, error) {
117116
var asnInfoList []ASNInfo
118117
var asnInfoType = reflect.TypeOf(asnInfoList)
119118

119+
var districtInfo DistrictInfo
120+
var districtInfoType = reflect.TypeOf(districtInfo)
121+
120122
info := &CityInfo{}
121123

122124
for k, v := range data {
@@ -139,6 +141,11 @@ func (db *City) FindInfo(addr, language string) (*CityInfo, error) {
139141
if err == nil {
140142
sfv.Set(reflect.ValueOf(asnInfoList))
141143
}
144+
} else if sft == districtInfoType {
145+
err = json.Unmarshal([]byte(v), &districtInfo)
146+
if err == nil {
147+
sfv.Set(reflect.ValueOf(districtInfo))
148+
}
142149
}
143150
}
144151

city_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ func TestNewCity(t *testing.T) {
4747
} else {
4848
t.Log(info.Route)
4949
t.Log(info.ASN)
50-
t.Log(info.DistrictName)
51-
t.Log(info.Radius)
50+
t.Log(info.DistrictInfo)
5251
t.Log(info.ASNInfo)
5352

5453
for _, af := range info.ASNInfo {

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
module github.com/ipipdotnet/ipdb-go
2+
3+
go 1.14

0 commit comments

Comments
 (0)