项目作者: DiSiqueira

项目描述 :
Simple currency converter. Insert an amount, what currency to convert from and what currency to convert to.
高级语言: Go
项目地址: git://github.com/DiSiqueira/GoCurrency.git
创建时间: 2017-03-19T08:48:40Z
项目社区:https://github.com/DiSiqueira/GoCurrency

开源协议:MIT License

下载


" class="reference-link">GoCurrency

Go Report License Badge Status Badge" class="reference-link">GoCurrency Language Badge Go Report License Badge Status Badge

GoCurrency is a Go program made on the top of Kund Nu Currency Converter API.

The GoCurrency’s goal is to be a perfect tool providing a stupidly easy-to-use and fast program to convert values between currencies.

Table of Contents

Demo

asciicast

Project Status

GoCurrency is on beta. Pull Requests are welcome

Features

  • Open source - You can check out our code
  • Secure
  • Always up-to-date
  • Use decimal type
  • 100% satisfaction guaranteed
  • It’s perfect to convert amounts between currencies
  • STUPIDLY EASY TO USE
  • Very fast start up and response time
  • Uses native libs

Installation

Option 1: Go Get

  1. $ go get github.com/disiqueira/gocurrency

Available Currencies

  • ATS Austria, shilling
  • AUD Australian, dollar
  • BEF Belgien, franc
  • BRL Brazilien, real
  • CAD Canada, dollar
  • CHF Switzerland, francs
  • CNY China, yuan renminbi
  • CYP Cyprus, pound
  • CZK Czech Republic, koruna
  • DEM Germany, mark
  • DKK Denmark, krone
  • EEK Estonian, kroon
  • ESP Spain, pesetas
  • EUR Euroland, euro
  • FIM Finland, marka
  • FRF France, franc
  • GBP Great Britain, pound
  • GRD Greece, drachmer
  • HKD Hong Kong, dollar
  • HUF Hungary, forint
  • IDR Indonesia, rupiah
  • IEP Ireland, pund
  • INR India, rupee
  • ISK Iceland, kronor
  • ITL Italy, lire
  • JPY Japan, yen
  • KRW South Korea, won
  • KWD Kuwait, dinar
  • LTL Lithuania, litas
  • LVL Latvia, lat
  • MAD Morocko, dirham
  • MXN Mexico, nuevo peso
  • MYR Malaysia, ringgit
  • NLG Dutchland, guilder
  • NOK Norway, krone
  • NZD New Zealand, dollar
  • PLN Poland, zloty
  • PTE Portugal, escudo
  • RUB Russia, rouble
  • SAR Saudi Arabia, riyal
  • SEK Sweden, kronor
  • SGD Singapore, dollar
  • SIT Slovenia, tolar
  • SKK Slovakia, koruna
  • THB Thailand, baht
  • TRL Turkey, lira
  • TRY Turkey, new lira
  • USD US, dollar
  • ZAR South Africa, rand

Usage

Get all available currencies

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/disiqueira/gocurrency"
  5. )
  6. func main() {
  7. curList, _ := gocurrency.AvailableCurrencies()
  8. for _, currency := range curList {
  9. fmt.Println(currency.Description)
  10. }
  11. }

Output:

  1. SEK Sweden, kronor
  2. ATS Austria, shilling
  3. AUD Australian, dollar
  4. BEF Belgien, franc
  5. BRL Brazilien, real
  6. CAD Canada, dollar
  7. CHF Switzerland, francs
  8. CNY China, yuan renminbi
  9. CYP Cyprus, pound
  10. CZK Czech Republic, koruna
  11. DEM Germany, mark
  12. DKK Denmark, krone
  13. EEK Estonian, kroon
  14. ESP Spain, pesetas
  15. EUR Euroland, euro
  16. FIM Finland, marka
  17. FRF France, franc
  18. GBP Great Britain, pound
  19. GRD Greece, drachmer
  20. HKD Hong Kong, dollar
  21. HUF Hungary, forint
  22. IDR Indonesia, rupiah
  23. IEP Ireland, pund
  24. INR India, rupee
  25. ISK Iceland, kronor
  26. ITL Italy, lire
  27. JPY Japan, yen
  28. KRW South Korea, won
  29. KWD Kuwait, dinar
  30. LTL Lithuania, litas
  31. LVL Latvia, lat
  32. MAD Morocko, dirham
  33. MXN Mexico, nuevo peso
  34. MYR Malaysia, ringgit
  35. NLG Dutchland, guilder
  36. NOK Norway, krone
  37. NZD New Zealand, dollar
  38. PLN Poland, zloty
  39. PTE Portugal, escudo
  40. RUB Russia, rouble
  41. SAR Saudi Arabia, riyal
  42. SGD Singapore, dollar
  43. SIT Slovenia, tolar
  44. SKK Slovakia, koruna
  45. THB Thailand, baht
  46. TRL Turkey, lira
  47. TRY Turkey, new lira
  48. USD US, dollar
  49. ZAR South Africa, rand

Convert 100 USD to all currencies

  1. package main
  2. import (
  3. "fmt"
  4. "strconv"
  5. "github.com/disiqueira/gocurrency"
  6. "github.com/shopspring/decimal"
  7. )
  8. func main() {
  9. curList, _ := gocurrency.AvailableCurrencies()
  10. dollar := gocurrency.NewCurrency("USD")
  11. amount := decimal.NewFromFloat(100.00)
  12. for _, currency := range curList {
  13. conv, _ := gocurrency.ConvertCurrency(dollar, currency, amount)
  14. fmt.Printf("%-3s %-8s --> %-3s %s\n", dollar.ID, amount, currency.ID, conv)
  15. }
  16. }

Output:

  1. USD 100.00 --> SEK 881.12
  2. USD 100.00 --> ATS 1334.36
  3. USD 100.00 --> AUD 130.28
  4. USD 100.00 --> BEF 3911.85
  5. USD 100.00 --> BRL 312.07
  6. USD 100.00 --> CAD 133.35
  7. USD 100.00 --> CHF 99.59
  8. USD 100.00 --> CNY 690.75
  9. USD 100.00 --> CYP 54.42
  10. USD 100.00 --> CZK 2509.74
  11. USD 100.00 --> DEM 189.66
  12. USD 100.00 --> DKK 690.54
  13. USD 100.00 --> EEK 1531.05
  14. USD 100.00 --> ESP 16134.77
  15. USD 100.00 --> EUR 92.88
  16. USD 100.00 --> FIM 576.57
  17. USD 100.00 --> FRF 636.10
  18. USD 100.00 --> GBP 80.95
  19. USD 100.00 --> GRD 33042.83
  20. USD 100.00 --> HKD 776.45
  21. USD 100.00 --> HUF 28765.63
  22. USD 100.00 --> IDR 1333010.59
  23. USD 100.00 --> IEP 76.37
  24. USD 100.00 --> INR 6553.27
  25. USD 100.00 --> ISK 10876.95
  26. USD 100.00 --> ITL 187751.97
  27. USD 100.00 --> JPY 11334.92
  28. USD 100.00 --> KRW 113239.94
  29. USD 100.00 --> KWD 37.74
  30. USD 100.00 --> LTL 319.77
  31. USD 100.00 --> LVL 69.22
  32. USD 100.00 --> MAD 999.46
  33. USD 100.00 --> MXN 1924.26
  34. USD 100.00 --> MYR 489.51
  35. USD 100.00 --> NLG 213.70
  36. USD 100.00 --> NOK 848.16
  37. USD 100.00 --> NZD 143.12
  38. USD 100.00 --> PLN 399.87
  39. USD 100.00 --> PTE 19441.33
  40. USD 100.00 --> RUB 5790.71
  41. USD 100.00 --> SAR 375.02
  42. USD 100.00 --> SGD 140.29
  43. USD 100.00 --> SIT 23310.05
  44. USD 100.00 --> SKK 0.00
  45. USD 100.00 --> THB 3490.97
  46. USD 100.00 --> TRL 176224000.00
  47. USD 100.00 --> TRY 360.64
  48. USD 100.00 --> USD 100.00
  49. USD 100.00 --> ZAR 1277.17

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Developing

PRs are welcome. To begin developing, do this:

  1. $ git clone https://github.com/disiqueira/gocurrency.git gocurrency
  2. $ cd gocurrency/
  3. $ go get -v -d

Social Coding

  1. Create an issue to discuss about your idea
  2. [Fork it] (https://github.com/DiSiqueira/GoCurrency/fork)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request
  7. Profit! :white_check_mark:

License

The MIT License (MIT)

Copyright (c) 2013-2017 Diego Siqueira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.