From 2b94bc01ece78de5d5a8529e4bebfedaec4f9183 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 7 Nov 2018 18:02:24 +0800 Subject: [PATCH] add new fields --- module/geoip/geoip.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/module/geoip/geoip.go b/module/geoip/geoip.go index 57dba0b..c66331d 100644 --- a/module/geoip/geoip.go +++ b/module/geoip/geoip.go @@ -17,7 +17,11 @@ func NewReader() (*geoip2.Reader, error) { // GeoStruct - type GeoStruct struct { - City string `json:"city"` + City string `json:"city"` + Country struct { + Name string `json:"name"` + Code string `json:"code"` + } `json:"country"` Timezone string `json:"timezone"` Location struct { Latitude float64 `json:"latitude"` @@ -37,5 +41,7 @@ func QueryGEO(input string) (geo *GeoStruct, err error) { geo.Timezone = record.Location.TimeZone geo.Location.Latitude = record.Location.Latitude geo.Location.Longitude = record.Location.Longitude + geo.Country.Code = record.Country.IsoCode + geo.Country.Name = record.Country.Names["en"] return }