+
Skip to content

gwsee/gocurrency

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gocurrency

Go Report Card Build Status cover.run GoDoc License

gocurrency 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",
    NameZH:         "对应的中文",
},

Install

go get -u github.com/gwsee/gocurrency

Usage

Get a list of countries (to iterate over, etc.)

for _, c := range gocurrency.Countries {
    fmt.Println(c.Name, c.Code, c.Currency)
}

Get a countries phone, name, currency symbol or currency

countryCode := "AU"
fmt.Printf("In %s where the phone ext is %s, the price is: %s10.00 (%s)",
    gocurrency.Name(countryCode),
    gocurrency.Phone(countryCode),
    gocurrency.CurrencySymbol(countryCode),
    gocurrency.Currency(countryCode))

// In Australia where the phone ext is +61, the price is: $10.00 (AUD)

Get a country

c := gocurrency.GetCountry(users.CountryCode)
fmt.Println(c.Name)
fmt.Println(c.Phone)
fmt.Println(c.Currency)

Get a list of names

names := gocurrency.CountryNames()
for _, c := range names{
    fmt.Println(c)
}

Get a list of codes

codes := gocurrency.CountryCodes()
for _, c := range codes{
    fmt.Println(c)
}

About

Country names, codes(iso2), phone extentions, currency and currency symbols

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载