Skip to content

Commit 214d935

Browse files
committed
feat: add country code to geoip json output
1 parent 0eb07b4 commit 214d935

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/geoip/geoip.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ func (g GeoIP) Find(query string, params ...string) (result fmt.Stringer, err er
4848
}
4949

5050
result = Result{
51-
Country: record.Country.Names[lang],
52-
Area: record.City.Names[lang],
51+
Country: record.Country.Names[lang],
52+
CountryCode: record.Country.IsoCode,
53+
Area: record.City.Names[lang],
5354
}
5455
return
5556
}
@@ -59,8 +60,9 @@ func (db GeoIP) Name() string {
5960
}
6061

6162
type Result struct {
62-
Country string `json:"country"`
63-
Area string `json:"area"`
63+
Country string `json:"country"`
64+
CountryCode string `json:"country_code"`
65+
Area string `json:"area"`
6466
}
6567

6668
func (r Result) String() string {

0 commit comments

Comments
 (0)