forked from amir_tavakolian/niki
22 lines
303 B
Go
22 lines
303 B
Go
package types
|
|
|
|
import "errors"
|
|
|
|
type Currency string
|
|
|
|
const (
|
|
IRR Currency = "IRR"
|
|
USD Currency = "USD"
|
|
)
|
|
|
|
func StringCastToCurrency(s string) (Currency, error) {
|
|
switch s {
|
|
case "IRR":
|
|
return IRR, nil
|
|
case "USD":
|
|
return USD, nil
|
|
default:
|
|
return IRR, errors.New("not a valid currency")
|
|
}
|
|
}
|