2
0
Эх сурвалжийг харах

Add country codes from maxmind csv file

use warnings;
use strict;
use Text::CSV qw( csv );

my $d = csv(in => "GeoLite2-Country-Locations-en.csv", headers => "auto");

use Data::Dump qw(pp);

for my $c (sort { $a->{country_iso_code} cmp $b->{country_iso_code}} @$d) {
    next unless $c->{country_name};
    my $cc = lc($c->{country_iso_code});
    my $co = lc($c->{continent_name});
    $co =~ s/\s+/-/;

    unless ($cc) {
        warn pp($c);
        next;
    }

    print qq["$cc":\t"$co",\n];
}
Ask Bjørn Hansen 3 жил өмнө
parent
commit
7ab39fadf5

+ 8 - 3
countries/countries.go

@@ -32,6 +32,7 @@ var CountryContinent = map[string]string{
 	"bm": "north-america",
 	"bn": "asia",
 	"bo": "south-america",
+	"bq": "north-america",
 	"br": "south-america",
 	"bs": "north-america",
 	"bt": "asia",
@@ -54,8 +55,9 @@ var CountryContinent = map[string]string{
 	"cr": "north-america",
 	"cu": "north-america",
 	"cv": "africa",
-	"cx": "asia",
-	"cy": "asia",
+	"cw": "north-america",
+	"cx": "oceania",
+	"cy": "europe",
 	"cz": "europe",
 	"de": "europe",
 	"dj": "africa",
@@ -210,8 +212,10 @@ var CountryContinent = map[string]string{
 	"sn": "africa",
 	"so": "africa",
 	"sr": "south-america",
+	"ss": "africa",
 	"st": "africa",
 	"sv": "north-america",
+	"sx": "north-america",
 	"sy": "asia",
 	"sz": "africa",
 	"tc": "north-america",
@@ -221,7 +225,7 @@ var CountryContinent = map[string]string{
 	"th": "asia",
 	"tj": "asia",
 	"tk": "oceania",
-	"tl": "asia",
+	"tl": "oceania",
 	"tm": "asia",
 	"tn": "africa",
 	"to": "oceania",
@@ -245,6 +249,7 @@ var CountryContinent = map[string]string{
 	"vu": "oceania",
 	"wf": "oceania",
 	"ws": "oceania",
+	"xk": "europe",
 	"ye": "asia",
 	"yt": "africa",
 	"za": "africa",