nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1diff --git a/pkg/geoip/geoip.go b/pkg/geoip/geoip.go
2index 6d913b9..13be7f5 100644
3--- a/pkg/geoip/geoip.go
4+++ b/pkg/geoip/geoip.go
5@@ -19,10 +19,12 @@ var (
6 )
7
8 type IPInfo struct {
9- Country string `maxminddb:"country"`
10- CountryName string `maxminddb:"country_name"`
11- Continent string `maxminddb:"continent"`
12- ContinentName string `maxminddb:"continent_name"`
13+ Country struct {
14+ IsoCode string `maxminddb:"iso_code"`
15+ } `maxminddb:"country"`
16+ Continent struct {
17+ Code string `maxminddb:"code"`
18+ } `maxminddb:"continent"`
19 }
20
21 func init() {
22@@ -44,10 +46,10 @@ func Lookup(ip net.IP, record *IPInfo) (string, error) {
23 return "", err
24 }
25
26- if record.Country != "" {
27- return strings.ToLower(record.Country), nil
28- } else if record.Continent != "" {
29- return strings.ToLower(record.Continent), nil
30+ if record.Country.IsoCode != "" {
31+ return strings.ToLower(record.Country.IsoCode), nil
32+ } else if record.Continent.Code != "" {
33+ return strings.ToLower(record.Continent.Code), nil
34 }
35
36 return "", fmt.Errorf("IP not found")