From 214d935a25edb87ca47c0449cf37160717410a32 Mon Sep 17 00:00:00 2001 From: zu1k Date: Mon, 11 Dec 2023 09:52:39 +0800 Subject: [PATCH] feat: add country code to geoip json output --- pkg/geoip/geoip.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/geoip/geoip.go b/pkg/geoip/geoip.go index 3e16f76..7b61450 100644 --- a/pkg/geoip/geoip.go +++ b/pkg/geoip/geoip.go @@ -48,8 +48,9 @@ func (g GeoIP) Find(query string, params ...string) (result fmt.Stringer, err er } result = Result{ - Country: record.Country.Names[lang], - Area: record.City.Names[lang], + Country: record.Country.Names[lang], + CountryCode: record.Country.IsoCode, + Area: record.City.Names[lang], } return } @@ -59,8 +60,9 @@ func (db GeoIP) Name() string { } type Result struct { - Country string `json:"country"` - Area string `json:"area"` + Country string `json:"country"` + CountryCode string `json:"country_code"` + Area string `json:"area"` } func (r Result) String() string {