add new fields

This commit is contained in:
Jay 2018-11-07 18:02:24 +08:00
parent 1e3ba45665
commit 2b94bc01ec

View File

@ -18,6 +18,10 @@ func NewReader() (*geoip2.Reader, error) {
// GeoStruct - // GeoStruct -
type GeoStruct struct { 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"` Timezone string `json:"timezone"`
Location struct { Location struct {
Latitude float64 `json:"latitude"` Latitude float64 `json:"latitude"`
@ -37,5 +41,7 @@ func QueryGEO(input string) (geo *GeoStruct, err error) {
geo.Timezone = record.Location.TimeZone geo.Timezone = record.Location.TimeZone
geo.Location.Latitude = record.Location.Latitude geo.Location.Latitude = record.Location.Latitude
geo.Location.Longitude = record.Location.Longitude geo.Location.Longitude = record.Location.Longitude
geo.Country.Code = record.Country.IsoCode
geo.Country.Name = record.Country.Names["en"]
return return
} }