Supported formats obtained from: * http://www.geopostcodes.com/GeoPC_Postal_codes_formats PostalCode yields a random postal/zip code for the given 2-letter country code. These codes are not guaranteed to refer to actually locations. They merely follow the correct format as far as letters and digits
(countrycode string)
| 15 | // They merely follow the correct format as far as letters and digits goes. |
| 16 | // Where possible, the function enforces valid ranges of letters and digits. |
| 17 | func PostalCode(countrycode string) string { |
| 18 | switch strings.ToUpper(countrycode) { |
| 19 | case "LS", "MG", "IS", "OM", "PG": |
| 20 | return Digits(3) |
| 21 | |
| 22 | case "AM", "GE", "NZ", "NE", "NO", "PY", "ZA", "MZ", "SJ", "LI", "AL", |
| 23 | "BD", "CV", "GL": |
| 24 | return Digits(4) |
| 25 | |
| 26 | case "DZ", "BA", "KH", "DO", "EG", "EE", "GP", "GT", "ID", "IL", "JO", |
| 27 | "KW", "MQ", "MX", "LK", "SD", "TR", "UA", "US", "CR", "IQ", "KV", "MY", |
| 28 | "MN", "ME", "PK", "SM", "MA", "UY", "EH", "ZM": |
| 29 | return Digits(5) |
| 30 | |
| 31 | case "BY", "CN", "IN", "KZ", "KG", "NG", "RO", "RU", "SG", "TJ", "TM", "UZ", "VN": |
| 32 | return Digits(6) |
| 33 | |
| 34 | case "CL": |
| 35 | return Digits(7) |
| 36 | |
| 37 | case "IR": |
| 38 | return Digits(10) |
| 39 | |
| 40 | case "FO": |
| 41 | return "FO " + Digits(3) |
| 42 | |
| 43 | case "AF": |
| 44 | return BoundedDigits(2, 10, 43) + BoundedDigits(2, 1, 99) |
| 45 | |
| 46 | case "AU", "AT", "BE", "BG", "CY", "DK", "ET", "GW", "HU", "LR", "MK", "PH", |
| 47 | "CH", "TN", "VE": |
| 48 | return BoundedDigits(4, 1000, 9999) |
| 49 | |
| 50 | case "SV": |
| 51 | return "CP " + BoundedDigits(4, 1000, 9999) |
| 52 | |
| 53 | case "HT": |
| 54 | return "HT" + Digits(4) |
| 55 | |
| 56 | case "LB": |
| 57 | return Digits(4) + " " + Digits(4) |
| 58 | |
| 59 | case "LU": |
| 60 | return BoundedDigits(4, 6600, 6999) |
| 61 | |
| 62 | case "MD": |
| 63 | return "MD-" + BoundedDigits(4, 1000, 9999) |
| 64 | |
| 65 | case "HR": |
| 66 | return "HR-" + Digits(5) |
| 67 | |
| 68 | case "CU": |
| 69 | return "CP " + BoundedDigits(5, 10000, 99999) |
| 70 | |
| 71 | case "FI": |
| 72 | // Last digit is usually 0 but can, in some cases, be 1 or 5. |
| 73 | switch privateRand.Intn(2) { |
| 74 | case 0: |
searching dependent graphs…