Fix select country

This commit is contained in:
世界 2024-10-09 20:15:19 +08:00
parent d4fc531179
commit 4be169b3d3
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4

14
main.go
View File

@ -91,18 +91,8 @@ func parse(binary []byte) (metadata maxminddb.Metadata, countryMap map[string][]
if err != nil {
return
}
var code string
if country.Country.IsoCode != "" {
code = strings.ToLower(country.Country.IsoCode)
} else if country.RegisteredCountry.IsoCode != "" {
code = strings.ToLower(country.RegisteredCountry.IsoCode)
} else if country.RepresentedCountry.IsoCode != "" {
code = strings.ToLower(country.RepresentedCountry.IsoCode)
} else if country.Continent.Code != "" {
code = strings.ToLower(country.Continent.Code)
} else {
continue
}
// idk why
code := country.RegisteredCountry.IsoCode
countryMap[code] = append(countryMap[code], ipNet)
}
err = networks.Err()