Skip to content

Commit

Permalink
currency code ToUpper
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikalai Konan authored and Mikalai Konan committed Jul 26, 2024
1 parent e8555fd commit e32a1bb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions currency/currency.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package currency

import (
"fmt"
"strings"
)

type currency struct {
Expand Down Expand Up @@ -50,7 +51,7 @@ func (currencies currencies) CurrencyByCurrency(curr string) (currency, bool) {
// CurrencyByCode gets currency by code
func (currencies currencies) CurrencyByCode(code string) (currency, bool) {
for _, c := range currencies {
if string(c.code) == code {
if string(c.code) == strings.ToUpper(code) {
return c, true
}
}
Expand All @@ -71,7 +72,7 @@ func (currencies currencies) CurrencyByNumber(number string) (currency, bool) {

// ByCodeStr lookup for currency type by code
func ByCodeStr(code string) (c currency, ok bool) {
c, ok = currenciesByCode[code]
c, ok = currenciesByCode[strings.ToUpper(code)]
return
}

Expand All @@ -96,7 +97,7 @@ func ByCountryStr(country string) (c currencies, ok bool) {
// ByCodeStrErr lookup for currency type by code
func ByCodeStrErr(code string) (c currency, err error) {
var ok bool
c, ok = currenciesByCode[code]
c, ok = currenciesByCode[strings.ToUpper(code)]

if !ok {
return currency{}, fmt.Errorf("'%s' is not valid ISO-4217 code", code)
Expand Down

0 comments on commit e32a1bb

Please sign in to comment.