Gowhere provides an easy way to get country data. See below for usage. Each country consists of the following struct:
Country{
Code: "AU", // iso2 code
Currency: "AUD",
CurrencySymbol: "$",
Phone: "+61",
Name: "Australia",
},
go get -u github.com/ae0000/gowhere
for _, c := range gowhere.Countries {
fmt.Println(c.Name, c.Code, c.Currency)
}
countryCode := "AU"
fmt.Printf("In %s where the phone ext is %s, the price is: %s10.00 (%s)",
gowhere.Name(countryCode),
gowhere.Phone(countryCode),
gowhere.CurrencySymbol(countryCode),
gowhere.Currency(countryCode))
// In Australia where the phone ext is +61, the price is: $10.00 (AUD)
c := gowhere.GetCountry(users.CountryCode)
fmt.Println(c.Name)
fmt.Println(c.Phone)
fmt.Println(c.Currency)
names := gowhere.CountryNames()
for _, c := range names{
fmt.Println(c)
}
codes := gowhere.CountryCodes()
for _, c := range codes{
fmt.Println(c)
}