add new fields

This commit is contained in:
Jay 2018-11-07 18:02:24 +08:00
parent 1e3ba45665
commit 2b94bc01ec
1 changed files with 7 additions and 1 deletions

View File

@ -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
}