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