diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a01f7bc --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.ar21.de/tom/country-geo-locations + +go 1.21.5 diff --git a/pkg/geoloc/data.go b/pkg/geoloc/data.go new file mode 100644 index 0000000..9ec8a44 --- /dev/null +++ b/pkg/geoloc/data.go @@ -0,0 +1,1969 @@ +package geoloc + +type Country struct { + Name string + Code string + Location Location +} + +type Location struct { + Latitude float32 + Longitude float32 +} + +var ( + countries = map[string]Country{ + "AD": { + Name: "Andorra", + Code: "AD", + Location: Location{ + Latitude: 42.55, + Longitude: 1.6, + }, + }, + "AE": { + Name: "United Arab Emirates", + Code: "AE", + Location: Location{ + Latitude: 23.42, + Longitude: 53.85, + }, + }, + "AF": { + Name: "Afghanistan", + Code: "AF", + Location: Location{ + Latitude: 33.94, + Longitude: 67.71, + }, + }, + "AG": { + Name: "Antigua And Barbuda", + Code: "AG", + Location: Location{ + Latitude: 17.06, + Longitude: -61.8, + }, + }, + "AI": { + Name: "Anguilla", + Code: "AI", + Location: Location{ + Latitude: 18.22, + Longitude: -63.07, + }, + }, + "AL": { + Name: "Albania", + Code: "AL", + Location: Location{ + Latitude: 41.15, + Longitude: 20.17, + }, + }, + "AM": { + Name: "Armenia", + Code: "AM", + Location: Location{ + Latitude: 40.07, + Longitude: 45.04, + }, + }, + "AN": { + Name: "Netherlands Antilles", + Code: "AN", + Location: Location{ + Latitude: 12.23, + Longitude: -69.06, + }, + }, + "AO": { + Name: "Angola", + Code: "AO", + Location: Location{ + Latitude: -11.2, + Longitude: 17.87, + }, + }, + "AR": { + Name: "Argentina", + Code: "AR", + Location: Location{ + Latitude: -38.42, + Longitude: -63.62, + }, + }, + "AS": { + Name: "American Samoa", + Code: "AS", + Location: Location{ + Latitude: -14.27, + Longitude: -170.13, + }, + }, + "AT": { + Name: "Austria", + Code: "AT", + Location: Location{ + Latitude: 47.52, + Longitude: 14.55, + }, + }, + "AU": { + Name: "Australia", + Code: "AU", + Location: Location{ + Latitude: -25.27, + Longitude: 133.78, + }, + }, + "AW": { + Name: "Aruba", + Code: "AW", + Location: Location{ + Latitude: 12.52, + Longitude: -69.97, + }, + }, + "AX": { + Name: "Aland Islands", + Code: "AX", + Location: Location{ + Latitude: 60.18, + Longitude: 19.92, + }, + }, + "AZ": { + Name: "Azerbaijan", + Code: "AZ", + Location: Location{ + Latitude: 40.14, + Longitude: 47.58, + }, + }, + "BA": { + Name: "Bosnia And Herzegovina", + Code: "BA", + Location: Location{ + Latitude: 43.92, + Longitude: 17.68, + }, + }, + "BB": { + Name: "Barbados", + Code: "BB", + Location: Location{ + Latitude: 13.19, + Longitude: -59.54, + }, + }, + "BD": { + Name: "Bangladesh", + Code: "BD", + Location: Location{ + Latitude: 23.68, + Longitude: 90.36, + }, + }, + "BE": { + Name: "Belgium", + Code: "BE", + Location: Location{ + Latitude: 50.5, + Longitude: 4.47, + }, + }, + "BF": { + Name: "Burkina Faso", + Code: "BF", + Location: Location{ + Latitude: 12.24, + Longitude: -1.56, + }, + }, + "BG": { + Name: "Bulgaria", + Code: "BG", + Location: Location{ + Latitude: 42.73, + Longitude: 25.49, + }, + }, + "BH": { + Name: "Bahrain", + Code: "BH", + Location: Location{ + Latitude: 25.93, + Longitude: 50.64, + }, + }, + "BI": { + Name: "Burundi", + Code: "BI", + Location: Location{ + Latitude: -3.37, + Longitude: 29.92, + }, + }, + "BJ": { + Name: "Benin", + Code: "BJ", + Location: Location{ + Latitude: 9.31, + Longitude: 2.32, + }, + }, + "BL": { + Name: "Saint Barthelemy", + Code: "BL", + Location: Location{ + Latitude: 17.9, + Longitude: -62.83, + }, + }, + "BM": { + Name: "Bermuda", + Code: "BM", + Location: Location{ + Latitude: 32.32, + Longitude: -64.76, + }, + }, + "BN": { + Name: "Brunei", + Code: "BN", + Location: Location{ + Latitude: 4.54, + Longitude: 114.73, + }, + }, + "BO": { + Name: "Bolivia", + Code: "BO", + Location: Location{ + Latitude: -16.29, + Longitude: -63.59, + }, + }, + "BQ": { + Name: "Bonaire", + Code: "BQ", + Location: Location{ + Latitude: 12.2, + Longitude: -68.26, + }, + }, + "BR": { + Name: "Brazil", + Code: "BR", + Location: Location{ + Latitude: -14.24, + Longitude: -51.39, + }, + }, + "BS": { + Name: "The Bahamas", + Code: "BS", + Location: Location{ + Latitude: 25.03, + Longitude: -77.4, + }, + }, + "BT": { + Name: "Bhutan", + Code: "BT", + Location: Location{ + Latitude: 27.51, + Longitude: 90.43, + }, + }, + "BV": { + Name: "Bouvet Island", + Code: "BV", + Location: Location{ + Latitude: -54.42, + Longitude: 3.41, + }, + }, + "BW": { + Name: "Botswana", + Code: "BW", + Location: Location{ + Latitude: -22.33, + Longitude: 24.68, + }, + }, + "BY": { + Name: "Belarus", + Code: "BY", + Location: Location{ + Latitude: 53.71, + Longitude: 27.95, + }, + }, + "BZ": { + Name: "Belize", + Code: "BZ", + Location: Location{ + Latitude: 17.19, + Longitude: -88.5, + }, + }, + "CA": { + Name: "Canada", + Code: "CA", + Location: Location{ + Latitude: 56.13, + Longitude: -106.35, + }, + }, + "CC": { + Name: "Cocos (Keeling) Islands", + Code: "CC", + Location: Location{ + Latitude: -12.16, + Longitude: 96.87, + }, + }, + "CD": { + Name: "Democratic Republic Of The Congo", + Code: "CD", + Location: Location{ + Latitude: -4.04, + Longitude: 21.76, + }, + }, + "CF": { + Name: "Central African Republic", + Code: "CF", + Location: Location{ + Latitude: 6.61, + Longitude: 20.94, + }, + }, + "CG": { + Name: "Republic Of The Congo", + Code: "CG", + Location: Location{ + Latitude: -0.23, + Longitude: 15.83, + }, + }, + "CH": { + Name: "Switzerland", + Code: "CH", + Location: Location{ + Latitude: 46.82, + Longitude: 8.23, + }, + }, + "CK": { + Name: "Cook Islands", + Code: "CK", + Location: Location{ + Latitude: -21.24, + Longitude: -159.78, + }, + }, + "CL": { + Name: "Chile", + Code: "CL", + Location: Location{ + Latitude: -35.68, + Longitude: 71.54, + }, + }, + "CM": { + Name: "Cameroon", + Code: "CM", + Location: Location{ + Latitude: 7.37, + Longitude: 12.35, + }, + }, + "CN": { + Name: "China", + Code: "CN", + Location: Location{ + Latitude: 35.86, + Longitude: 104.2, + }, + }, + "CO": { + Name: "Colombia", + Code: "CO", + Location: Location{ + Latitude: 4.57, + Longitude: -74.3, + }, + }, + "CR": { + Name: "Costa Rica", + Code: "CR", + Location: Location{ + Latitude: 9.75, + Longitude: -83.75, + }, + }, + "CU": { + Name: "Cuba", + Code: "CU", + Location: Location{ + Latitude: 21.52, + Longitude: -77.78, + }, + }, + "CV": { + Name: "Cape Verde", + Code: "CV", + Location: Location{ + Latitude: 16, + Longitude: -24.01, + }, + }, + "CW": { + Name: "Curacao", + Code: "CW", + Location: Location{ + Latitude: 12.17, + Longitude: -68.99, + }, + }, + "CX": { + Name: "Christmas Island", + Code: "CX", + Location: Location{ + Latitude: -10.45, + Longitude: 105.69, + }, + }, + "CY": { + Name: "Cyprus", + Code: "CY", + Location: Location{ + Latitude: 35.13, + Longitude: 33.43, + }, + }, + "CZ": { + Name: "Czech Republic", + Code: "CZ", + Location: Location{ + Latitude: 49.82, + Longitude: 15.47, + }, + }, + "DE": { + Name: "Germany", + Code: "DE", + Location: Location{ + Latitude: 51.17, + Longitude: 10.45, + }, + }, + "DJ": { + Name: "Djibouti", + Code: "DJ", + Location: Location{ + Latitude: 11.83, + Longitude: 42.59, + }, + }, + "DK": { + Name: "Denmark", + Code: "DK", + Location: Location{ + Latitude: 56.26, + Longitude: 9.5, + }, + }, + "DM": { + Name: "Dominica", + Code: "DM", + Location: Location{ + Latitude: 15.41, + Longitude: -61.37, + }, + }, + "DO": { + Name: "Dominican Republic", + Code: "DO", + Location: Location{ + Latitude: 18.74, + Longitude: -70.16, + }, + }, + "DZ": { + Name: "Algeria", + Code: "DZ", + Location: Location{ + Latitude: 28.03, + Longitude: 1.66, + }, + }, + "EC": { + Name: "Ecuador", + Code: "EC", + Location: Location{ + Latitude: -1.83, + Longitude: -78.18, + }, + }, + "EE": { + Name: "Estonia", + Code: "EE", + Location: Location{ + Latitude: 58.6, + Longitude: 25.01, + }, + }, + "EG": { + Name: "Egypt", + Code: "EG", + Location: Location{ + Latitude: 26.82, + Longitude: 30.8, + }, + }, + "EH": { + Name: "Western Sahara", + Code: "EH", + Location: Location{ + Latitude: 24.22, + Longitude: -12.89, + }, + }, + "ER": { + Name: "Eritrea", + Code: "ER", + Location: Location{ + Latitude: 15.18, + Longitude: 39.78, + }, + }, + "ES": { + Name: "Spain", + Code: "ES", + Location: Location{ + Latitude: 40.46, + Longitude: -3.75, + }, + }, + "ET": { + Name: "Ethiopia", + Code: "ET", + Location: Location{ + Latitude: 9.15, + Longitude: 40.49, + }, + }, + "FI": { + Name: "Finland", + Code: "FI", + Location: Location{ + Latitude: 61.92, + Longitude: 25.75, + }, + }, + "FJ": { + Name: "Fiji", + Code: "FJ", + Location: Location{ + Latitude: -16.58, + Longitude: 179.41, + }, + }, + "FK": { + Name: "Falkland Islands", + Code: "FK", + Location: Location{ + Latitude: -51.8, + Longitude: 59.52, + }, + }, + "FM": { + Name: "Micronesia", + Code: "FM", + Location: Location{ + Latitude: 7.43, + Longitude: 150.55, + }, + }, + "FO": { + Name: "Faroe Islands", + Code: "FO", + Location: Location{ + Latitude: 61.89, + Longitude: -6.91, + }, + }, + "FR": { + Name: "France", + Code: "FR", + Location: Location{ + Latitude: 46.23, + Longitude: 2.21, + }, + }, + "GA": { + Name: "Gabon", + Code: "GA", + Location: Location{ + Latitude: -0.8, + Longitude: 11.61, + }, + }, + "GB": { + Name: "United Kingdom", + Code: "GB", + Location: Location{ + Latitude: 55.38, + Longitude: -3.44, + }, + }, + "GD": { + Name: "Grenada", + Code: "GD", + Location: Location{ + Latitude: 12.26, + Longitude: -61.6, + }, + }, + "GE": { + Name: "Georgia", + Code: "GE", + Location: Location{ + Latitude: 42.32, + Longitude: 43.36, + }, + }, + "GF": { + Name: "French Guiana", + Code: "GF", + Location: Location{ + Latitude: 3.93, + Longitude: -53.13, + }, + }, + "GG": { + Name: "Guernsey", + Code: "GG", + Location: Location{ + Latitude: 49.47, + Longitude: -2.59, + }, + }, + "GH": { + Name: "Ghana", + Code: "GH", + Location: Location{ + Latitude: 7.95, + Longitude: -1.02, + }, + }, + "GI": { + Name: "Gibraltar", + Code: "GI", + Location: Location{ + Latitude: 36.14, + Longitude: -5.35, + }, + }, + "GL": { + Name: "Greenland", + Code: "GL", + Location: Location{ + Latitude: 71.71, + Longitude: 42.6, + }, + }, + "GM": { + Name: "Gambia", + Code: "GM", + Location: Location{ + Latitude: 13.44, + Longitude: -15.31, + }, + }, + "GN": { + Name: "Guinea", + Code: "GN", + Location: Location{ + Latitude: 9.95, + Longitude: -9.7, + }, + }, + "GP": { + Name: "Guadeloupe", + Code: "GP", + Location: Location{ + Latitude: 17, + Longitude: -62.07, + }, + }, + "GQ": { + Name: "Equatorial Guinea", + Code: "GQ", + Location: Location{ + Latitude: 1.65, + Longitude: 10.27, + }, + }, + "GR": { + Name: "Greece", + Code: "GR", + Location: Location{ + Latitude: 39.07, + Longitude: 21.82, + }, + }, + "GS": { + Name: "South Georgia And The South Sandwich Islands", + Code: "GS", + Location: Location{ + Latitude: -54.43, + Longitude: -36.59, + }, + }, + "GT": { + Name: "Guatemala", + Code: "GT", + Location: Location{ + Latitude: 15.78, + Longitude: -90.23, + }, + }, + "GU": { + Name: "Guam", + Code: "GU", + Location: Location{ + Latitude: 13.44, + Longitude: 144.79, + }, + }, + "GW": { + Name: "Guinea-Bissau", + Code: "GW", + Location: Location{ + Latitude: 11.8, + Longitude: -15.18, + }, + }, + "GY": { + Name: "Guyana", + Code: "GY", + Location: Location{ + Latitude: 4.86, + Longitude: -58.93, + }, + }, + "HK": { + Name: "Hong Kong", + Code: "HK", + Location: Location{ + Latitude: 22.4, + Longitude: 114.11, + }, + }, + "HN": { + Name: "Honduras", + Code: "HN", + Location: Location{ + Latitude: 15.2, + Longitude: -86.24, + }, + }, + "HR": { + Name: "Croatia", + Code: "HR", + Location: Location{ + Latitude: 45.1, + Longitude: 15.2, + }, + }, + "HT": { + Name: "Haiti", + Code: "HT", + Location: Location{ + Latitude: 18.97, + Longitude: -72.29, + }, + }, + "HU": { + Name: "Hungary", + Code: "HU", + Location: Location{ + Latitude: 47.16, + Longitude: 19.5, + }, + }, + "ID": { + Name: "Indonesia", + Code: "ID", + Location: Location{ + Latitude: -0.79, + Longitude: 113.92, + }, + }, + "IE": { + Name: "Ireland", + Code: "IE", + Location: Location{ + Latitude: 53.41, + Longitude: -8.24, + }, + }, + "IL": { + Name: "Israel", + Code: "IL", + Location: Location{ + Latitude: 31.05, + Longitude: 34.85, + }, + }, + "IM": { + Name: "Isle Of Man", + Code: "IM", + Location: Location{ + Latitude: 54.24, + Longitude: -4.55, + }, + }, + "IN": { + Name: "India", + Code: "IN", + Location: Location{ + Latitude: 20.59, + Longitude: 78.96, + }, + }, + "IO": { + Name: "British Indian Ocean Territory", + Code: "IO", + Location: Location{ + Latitude: -6.34, + Longitude: 71.88, + }, + }, + "IQ": { + Name: "Iraq", + Code: "IQ", + Location: Location{ + Latitude: 33.22, + Longitude: 43.68, + }, + }, + "IR": { + Name: "Iran", + Code: "IR", + Location: Location{ + Latitude: 32.43, + Longitude: 53.69, + }, + }, + "IS": { + Name: "Iceland", + Code: "IS", + Location: Location{ + Latitude: 64.96, + Longitude: -19.02, + }, + }, + "IT": { + Name: "Italy", + Code: "IT", + Location: Location{ + Latitude: 41.87, + Longitude: 12.57, + }, + }, + "JE": { + Name: "Jersey", + Code: "JE", + Location: Location{ + Latitude: 49.21, + Longitude: -2.13, + }, + }, + "JM": { + Name: "Jamaica", + Code: "JM", + Location: Location{ + Latitude: 18.11, + Longitude: -77.3, + }, + }, + "JO": { + Name: "Jordan", + Code: "JO", + Location: Location{ + Latitude: 30.59, + Longitude: 36.24, + }, + }, + "JP": { + Name: "Japan", + Code: "JP", + Location: Location{ + Latitude: 36.2, + Longitude: 138.25, + }, + }, + "KE": { + Name: "Kenya", + Code: "KE", + Location: Location{ + Latitude: -0.02, + Longitude: 37.91, + }, + }, + "KG": { + Name: "Kyrgyzstan", + Code: "KG", + Location: Location{ + Latitude: 41.2, + Longitude: 74.77, + }, + }, + "KH": { + Name: "Cambodia", + Code: "KH", + Location: Location{ + Latitude: 12.57, + Longitude: 104.99, + }, + }, + "KI": { + Name: "Kiribati", + Code: "KI", + Location: Location{ + Latitude: -3.37, + Longitude: -168.73, + }, + }, + "KM": { + Name: "Comoros", + Code: "KM", + Location: Location{ + Latitude: -11.88, + Longitude: 43.87, + }, + }, + "KN": { + Name: "Saint Kitts And Nevis", + Code: "KN", + Location: Location{ + Latitude: 17.36, + Longitude: -62.78, + }, + }, + "KP": { + Name: "North Korea", + Code: "KP", + Location: Location{ + Latitude: 40.34, + Longitude: 127.51, + }, + }, + "KR": { + Name: "South Korea", + Code: "KR", + Location: Location{ + Latitude: 35.91, + Longitude: 127.77, + }, + }, + "KW": { + Name: "Kuwait", + Code: "KW", + Location: Location{ + Latitude: 29.31, + Longitude: 47.48, + }, + }, + "KY": { + Name: "Cayman Islands", + Code: "KY", + Location: Location{ + Latitude: 19.51, + Longitude: -80.57, + }, + }, + "KZ": { + Name: "Kazakhstan", + Code: "KZ", + Location: Location{ + Latitude: 48.02, + Longitude: 66.92, + }, + }, + "LA": { + Name: "Laos", + Code: "LA", + Location: Location{ + Latitude: 19.86, + Longitude: 102.5, + }, + }, + "LB": { + Name: "Lebanon", + Code: "LB", + Location: Location{ + Latitude: 33.85, + Longitude: 35.86, + }, + }, + "LC": { + Name: "Saint Lucia", + Code: "LC", + Location: Location{ + Latitude: 13.91, + Longitude: -60.98, + }, + }, + "LI": { + Name: "Liechtenstein", + Code: "LI", + Location: Location{ + Latitude: 47.17, + Longitude: 9.56, + }, + }, + "LK": { + Name: "Sri Lanka", + Code: "LK", + Location: Location{ + Latitude: 7.87, + Longitude: 80.77, + }, + }, + "LR": { + Name: "Liberia", + Code: "LR", + Location: Location{ + Latitude: 6.43, + Longitude: -9.43, + }, + }, + "LS": { + Name: "Lesotho", + Code: "LS", + Location: Location{ + Latitude: -29.61, + Longitude: 28.23, + }, + }, + "LT": { + Name: "Lithuania", + Code: "LT", + Location: Location{ + Latitude: 55.17, + Longitude: 23.88, + }, + }, + "LU": { + Name: "Luxembourg", + Code: "LU", + Location: Location{ + Latitude: 49.82, + Longitude: 6.13, + }, + }, + "LV": { + Name: "Latvia", + Code: "LV", + Location: Location{ + Latitude: 56.88, + Longitude: 24.6, + }, + }, + "LY": { + Name: "Libya", + Code: "LY", + Location: Location{ + Latitude: 26.34, + Longitude: 17.23, + }, + }, + "MA": { + Name: "Morocco", + Code: "MA", + Location: Location{ + Latitude: 31.79, + Longitude: -7.09, + }, + }, + "MC": { + Name: "Monaco", + Code: "MC", + Location: Location{ + Latitude: 43.75, + Longitude: 7.41, + }, + }, + "MD": { + Name: "Moldova", + Code: "MD", + Location: Location{ + Latitude: 47.41, + Longitude: 28.37, + }, + }, + "ME": { + Name: "Montenegro", + Code: "ME", + Location: Location{ + Latitude: 42.71, + Longitude: 19.37, + }, + }, + "MF": { + Name: "Saint Martin", + Code: "MF", + Location: Location{ + Latitude: 18.07, + Longitude: -63.05, + }, + }, + "MG": { + Name: "Madagascar", + Code: "MG", + Location: Location{ + Latitude: -18.77, + Longitude: 46.87, + }, + }, + "MH": { + Name: "Marshall Islands", + Code: "MH", + Location: Location{ + Latitude: 7.13, + Longitude: 171.18, + }, + }, + "MK": { + Name: "Macedonia", + Code: "MK", + Location: Location{ + Latitude: 41.61, + Longitude: 21.75, + }, + }, + "ML": { + Name: "Mali", + Code: "ML", + Location: Location{ + Latitude: 17.57, + Longitude: -4, + }, + }, + "MM": { + Name: "Myanmar (Burma)", + Code: "MM", + Location: Location{ + Latitude: 21.91, + Longitude: 95.96, + }, + }, + "MN": { + Name: "Mongolia", + Code: "MN", + Location: Location{ + Latitude: 46.86, + Longitude: 103.85, + }, + }, + "MO": { + Name: "Macau", + Code: "MO", + Location: Location{ + Latitude: 22.2, + Longitude: 113.54, + }, + }, + "MP": { + Name: "Northern Mariana Islands", + Code: "MP", + Location: Location{ + Latitude: 17.33, + Longitude: 145.38, + }, + }, + "MQ": { + Name: "Martinique", + Code: "MQ", + Location: Location{ + Latitude: 14.64, + Longitude: 61.02, + }, + }, + "MR": { + Name: "Mauritania", + Code: "MR", + Location: Location{ + Latitude: 21.01, + Longitude: -10.94, + }, + }, + "MS": { + Name: "Montserrat", + Code: "MS", + Location: Location{ + Latitude: 16.74, + Longitude: -62.19, + }, + }, + "MT": { + Name: "Malta", + Code: "MT", + Location: Location{ + Latitude: 35.94, + Longitude: 14.38, + }, + }, + "MU": { + Name: "Mauritius", + Code: "MU", + Location: Location{ + Latitude: -20.35, + Longitude: 57.55, + }, + }, + "MV": { + Name: "Maldives", + Code: "MV", + Location: Location{ + Latitude: 3.2, + Longitude: 73.22, + }, + }, + "MW": { + Name: "Malawi", + Code: "MW", + Location: Location{ + Latitude: -13.25, + Longitude: 34.3, + }, + }, + "MX": { + Name: "Mexico", + Code: "MX", + Location: Location{ + Latitude: 23.63, + Longitude: -102.55, + }, + }, + "MY": { + Name: "Malaysia", + Code: "MY", + Location: Location{ + Latitude: 4.21, + Longitude: 101.98, + }, + }, + "MZ": { + Name: "Mozambique", + Code: "MZ", + Location: Location{ + Latitude: -18.67, + Longitude: 35.53, + }, + }, + "NA": { + Name: "Namibia", + Code: "NA", + Location: Location{ + Latitude: -22.96, + Longitude: 18.49, + }, + }, + "NC": { + Name: "New Caledonia", + Code: "NC", + Location: Location{ + Latitude: -20.9, + Longitude: 165.62, + }, + }, + "NE": { + Name: "Niger", + Code: "NE", + Location: Location{ + Latitude: 17.61, + Longitude: 8.08, + }, + }, + "NF": { + Name: "Norfolk Island", + Code: "NF", + Location: Location{ + Latitude: -29.04, + Longitude: 167.95, + }, + }, + "NG": { + Name: "Nigeria", + Code: "NG", + Location: Location{ + Latitude: 9.08, + Longitude: 8.68, + }, + }, + "NI": { + Name: "Nicaragua", + Code: "NI", + Location: Location{ + Latitude: 12.87, + Longitude: -85.21, + }, + }, + "NL": { + Name: "Netherlands", + Code: "NL", + Location: Location{ + Latitude: 52.13, + Longitude: 5.29, + }, + }, + "NO": { + Name: "Norway", + Code: "NO", + Location: Location{ + Latitude: 60.47, + Longitude: 8.47, + }, + }, + "NP": { + Name: "Nepal", + Code: "NP", + Location: Location{ + Latitude: 28.39, + Longitude: 84.12, + }, + }, + "NR": { + Name: "Nauru", + Code: "NR", + Location: Location{ + Latitude: -0.52, + Longitude: 166.93, + }, + }, + "NU": { + Name: "Niue", + Code: "NU", + Location: Location{ + Latitude: -19.05, + Longitude: -169.87, + }, + }, + "NZ": { + Name: "New Zealand", + Code: "NZ", + Location: Location{ + Latitude: -40.9, + Longitude: 174.89, + }, + }, + "OM": { + Name: "Oman", + Code: "OM", + Location: Location{ + Latitude: 21.51, + Longitude: 55.92, + }, + }, + "PA": { + Name: "Panama", + Code: "PA", + Location: Location{ + Latitude: 8.54, + Longitude: -80.78, + }, + }, + "PE": { + Name: "Peru", + Code: "PE", + Location: Location{ + Latitude: -9.19, + Longitude: -75.02, + }, + }, + "PF": { + Name: "French Polynesia", + Code: "PF", + Location: Location{ + Latitude: -17.68, + Longitude: -149.41, + }, + }, + "PG": { + Name: "Papua New Guinea", + Code: "PG", + Location: Location{ + Latitude: -6.31, + Longitude: 143.96, + }, + }, + "PH": { + Name: "Philippines", + Code: "PH", + Location: Location{ + Latitude: 12.88, + Longitude: 121.77, + }, + }, + "PK": { + Name: "Pakistan", + Code: "PK", + Location: Location{ + Latitude: 30.38, + Longitude: 69.35, + }, + }, + "PL": { + Name: "Poland", + Code: "PL", + Location: Location{ + Latitude: 51.92, + Longitude: 19.15, + }, + }, + "PM": { + Name: "Saint Pierre And Miquelon", + Code: "PM", + Location: Location{ + Latitude: 46.94, + Longitude: -56.27, + }, + }, + "PN": { + Name: "Pitcairn Islands", + Code: "PN", + Location: Location{ + Latitude: -24.7, + Longitude: -127.44, + }, + }, + "PR": { + Name: "Puerto Rico", + Code: "PR", + Location: Location{ + Latitude: 18.22, + Longitude: -66.59, + }, + }, + "PT": { + Name: "Portugal", + Code: "PT", + Location: Location{ + Latitude: 39.4, + Longitude: -8.22, + }, + }, + "PW": { + Name: "Palau", + Code: "PW", + Location: Location{ + Latitude: 7.51, + Longitude: 134.58, + }, + }, + "PY": { + Name: "Paraguay", + Code: "PY", + Location: Location{ + Latitude: -23.44, + Longitude: -58.44, + }, + }, + "QA": { + Name: "Qatar", + Code: "QA", + Location: Location{ + Latitude: 25.35, + Longitude: 51.18, + }, + }, + "RE": { + Name: "Reunion", + Code: "RE", + Location: Location{ + Latitude: -21.12, + Longitude: 55.54, + }, + }, + "RO": { + Name: "Romania", + Code: "RO", + Location: Location{ + Latitude: 45.94, + Longitude: 24.97, + }, + }, + "RS": { + Name: "Serbia", + Code: "RS", + Location: Location{ + Latitude: 44.02, + Longitude: 21.01, + }, + }, + "RU": { + Name: "Russia", + Code: "RU", + Location: Location{ + Latitude: 61.52, + Longitude: 105.32, + }, + }, + "RW": { + Name: "Rwanda", + Code: "RW", + Location: Location{ + Latitude: -1.94, + Longitude: 29.87, + }, + }, + "SA": { + Name: "Saudi Arabia", + Code: "SA", + Location: Location{ + Latitude: 23.89, + Longitude: 45.08, + }, + }, + "SB": { + Name: "Solomon Islands", + Code: "SB", + Location: Location{ + Latitude: -9.65, + Longitude: 160.16, + }, + }, + "SC": { + Name: "Seychelles", + Code: "SC", + Location: Location{ + Latitude: -4.68, + Longitude: 55.49, + }, + }, + "SD": { + Name: "Sudan", + Code: "SD", + Location: Location{ + Latitude: 12.86, + Longitude: 30.22, + }, + }, + "SE": { + Name: "Sweden", + Code: "SE", + Location: Location{ + Latitude: 60.13, + Longitude: 18.64, + }, + }, + "SG": { + Name: "Singapore", + Code: "SG", + Location: Location{ + Latitude: 1.35, + Longitude: 103.82, + }, + }, + "SH": { + Name: "Saint Helena", + Code: "SH", + Location: Location{ + Latitude: -24.14, + Longitude: -10.03, + }, + }, + "SI": { + Name: "Slovenia", + Code: "SI", + Location: Location{ + Latitude: 46.15, + Longitude: 15, + }, + }, + "SJ": { + Name: "Svalbard And Jan Mayen", + Code: "SJ", + Location: Location{ + Latitude: 77.55, + Longitude: 23.67, + }, + }, + "SK": { + Name: "Slovakia", + Code: "SK", + Location: Location{ + Latitude: 48.67, + Longitude: 19.7, + }, + }, + "SL": { + Name: "Sierra Leone", + Code: "SL", + Location: Location{ + Latitude: 8.46, + Longitude: -11.78, + }, + }, + "SM": { + Name: "San Marino", + Code: "SM", + Location: Location{ + Latitude: 43.94, + Longitude: 12.46, + }, + }, + "SN": { + Name: "Senegal", + Code: "SN", + Location: Location{ + Latitude: 14.5, + Longitude: -14.45, + }, + }, + "SO": { + Name: "Somalia", + Code: "SO", + Location: Location{ + Latitude: 5.15, + Longitude: 46.2, + }, + }, + "SR": { + Name: "SuriName", + Code: "SR", + Location: Location{ + Latitude: 3.92, + Longitude: -56.03, + }, + }, + "ST": { + Name: "Sao Tome And Principe", + Code: "ST", + Location: Location{ + Latitude: 0.19, + Longitude: 6.61, + }, + }, + "SV": { + Name: "El Salvador", + Code: "SV", + Location: Location{ + Latitude: 13.79, + Longitude: -88.9, + }, + }, + "SX": { + Name: "Sint Maarten", + Code: "SX", + Location: Location{ + Latitude: 18.03, + Longitude: -63.05, + }, + }, + "SY": { + Name: "Syria", + Code: "SY", + Location: Location{ + Latitude: 34.8, + Longitude: 39, + }, + }, + "SZ": { + Name: "Swaziland", + Code: "SZ", + Location: Location{ + Latitude: -26.52, + Longitude: 31.47, + }, + }, + "TC": { + Name: "Turks And Caicos Islands", + Code: "TC", + Location: Location{ + Latitude: 21.69, + Longitude: -71.8, + }, + }, + "TD": { + Name: "Chad", + Code: "TD", + Location: Location{ + Latitude: 15.45, + Longitude: 18.73, + }, + }, + "TG": { + Name: "Togo", + Code: "TG", + Location: Location{ + Latitude: 8.62, + Longitude: 0.82, + }, + }, + "TH": { + Name: "Thailand", + Code: "TH", + Location: Location{ + Latitude: 15.87, + Longitude: 100.99, + }, + }, + "TJ": { + Name: "Tajikistan", + Code: "TJ", + Location: Location{ + Latitude: 38.86, + Longitude: 71.28, + }, + }, + "TK": { + Name: "Tokelau", + Code: "TK", + Location: Location{ + Latitude: -8.97, + Longitude: -171.86, + }, + }, + "TL": { + Name: "Timor-Leste", + Code: "TL", + Location: Location{ + Latitude: -8.87, + Longitude: 125.73, + }, + }, + "TM": { + Name: "Turkmenistan", + Code: "TM", + Location: Location{ + Latitude: 38.97, + Longitude: 59.56, + }, + }, + "TN": { + Name: "Tunisia", + Code: "TN", + Location: Location{ + Latitude: 33.89, + Longitude: 9.54, + }, + }, + "TO": { + Name: "Tonga", + Code: "TO", + Location: Location{ + Latitude: -21.18, + Longitude: -175.2, + }, + }, + "TR": { + Name: "Turkey", + Code: "TR", + Location: Location{ + Latitude: 38.96, + Longitude: 35.24, + }, + }, + "TT": { + Name: "Trinidad And Tobago", + Code: "TT", + Location: Location{ + Latitude: 10.69, + Longitude: -61.22, + }, + }, + "TV": { + Name: "Tuvalu", + Code: "TV", + Location: Location{ + Latitude: -7.11, + Longitude: 177.65, + }, + }, + "TW": { + Name: "Taiwan", + Code: "TW", + Location: Location{ + Latitude: 23.7, + Longitude: 120.96, + }, + }, + "TZ": { + Name: "Tanzania", + Code: "TZ", + Location: Location{ + Latitude: -6.37, + Longitude: 34.89, + }, + }, + "UA": { + Name: "Ukraine", + Code: "UA", + Location: Location{ + Latitude: 48.38, + Longitude: 31.17, + }, + }, + "UG": { + Name: "Uganda", + Code: "UG", + Location: Location{ + Latitude: 1.37, + Longitude: 32.29, + }, + }, + "US": { + Name: "United States Of America", + Code: "US", + Location: Location{ + Latitude: 37.09, + Longitude: -95.71, + }, + }, + "UY": { + Name: "Uruguay", + Code: "UY", + Location: Location{ + Latitude: -32.52, + Longitude: -55.77, + }, + }, + "UZ": { + Name: "Uzbekistan", + Code: "UZ", + Location: Location{ + Latitude: 41.38, + Longitude: 64.59, + }, + }, + "VA": { + Name: "Vatican City", + Code: "VA", + Location: Location{ + Latitude: 41.9, + Longitude: 12.45, + }, + }, + "VC": { + Name: "Saint Vincent And The Grenadines", + Code: "VC", + Location: Location{ + Latitude: 12.98, + Longitude: -61.29, + }, + }, + "VE": { + Name: "Venezuela", + Code: "VE", + Location: Location{ + Latitude: 6.42, + Longitude: -66.59, + }, + }, + "VG": { + Name: "British Virgin Islands", + Code: "VG", + Location: Location{ + Latitude: 18.42, + Longitude: -64.64, + }, + }, + "VI": { + Name: "US Virgin Islands", + Code: "VI", + Location: Location{ + Latitude: 18.34, + Longitude: -64.9, + }, + }, + "VN": { + Name: "Vietnam", + Code: "VN", + Location: Location{ + Latitude: 14.06, + Longitude: 108.28, + }, + }, + "VU": { + Name: "Vanuatu", + Code: "VU", + Location: Location{ + Latitude: -15.38, + Longitude: 166.96, + }, + }, + "WF": { + Name: "Wallis And Futuna", + Code: "WF", + Location: Location{ + Latitude: -13.77, + Longitude: -177.16, + }, + }, + "WS": { + Name: "Samoa", + Code: "WS", + Location: Location{ + Latitude: -13.76, + Longitude: -172.1, + }, + }, + "XK": { + Name: "Kosovo", + Code: "XK", + Location: Location{ + Latitude: 42.6, + Longitude: 20.9, + }, + }, + "YE": { + Name: "Yemen", + Code: "YE", + Location: Location{ + Latitude: 15.55, + Longitude: 48.52, + }, + }, + "YT": { + Name: "Mayotte", + Code: "YT", + Location: Location{ + Latitude: -12.83, + Longitude: 45.17, + }, + }, + "ZA": { + Name: "South Africa", + Code: "ZA", + Location: Location{ + Latitude: -30.56, + Longitude: 22.94, + }, + }, + "ZM": { + Name: "Zambia", + Code: "ZM", + Location: Location{ + Latitude: -13.13, + Longitude: 27.85, + }, + }, + "ZW": { + Name: "Zimbabwe", + Code: "ZW", + Location: Location{ + Latitude: -19.02, + Longitude: 29.15, + }, + }, + } +) diff --git a/pkg/geoloc/main.go b/pkg/geoloc/main.go new file mode 100644 index 0000000..4e092fc --- /dev/null +++ b/pkg/geoloc/main.go @@ -0,0 +1,10 @@ +package geoloc + +import "strings" + +func GetCountry(input string) *Country { + if c, exists := countries[strings.ToUpper(input)]; exists { + return &c + } + return nil +} diff --git a/pkg/geoloc/main_test.go b/pkg/geoloc/main_test.go new file mode 100644 index 0000000..c0045fa --- /dev/null +++ b/pkg/geoloc/main_test.go @@ -0,0 +1,33 @@ +package geoloc + +import ( + "reflect" + "testing" +) + +func TestGetCountry(t *testing.T) { + type args struct { + input string + } + tests := []struct { + name string + args args + want *Country + }{ + {"GBR Test", args{input: "826"}, nil}, + {"USA upper Test", args{input: "USA"}, nil}, + {"Nothing Test", args{input: ""}, nil}, + {"Åland Islands Test", args{input: "Aland Islands"}, nil}, + {"Bahreïn Test", args{input: "Bahreïn"}, nil}, + {"Bahreïn Test (FR)", args{input: "Bahrein"}, nil}, + {"USA uppter Test", args{input: "US"}, GetCountry("US")}, + {"USA lower Test", args{input: "us"}, GetCountry("US")}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := GetCountry(tt.args.input); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCountry() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..60386d6 --- /dev/null +++ b/renovate.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "packageRules": [ + { + "matchPackagePatterns": ["*"], + "automerge": true, + "automergeType": "pr", + "platformAutomerge": true + } + ] +} \ No newline at end of file