Du kan inte välja fler än 25 ämnen
Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
45 rader
954 B
45 rader
954 B
package arg
|
|
|
|
import "fmt"
|
|
|
|
// FormatCurrency types format.
|
|
type FormatCurrency int
|
|
|
|
// Currency format.
|
|
const (
|
|
CurrencyFormatSymbol FormatCurrency = iota + 1
|
|
CurrencyFormatISO
|
|
CurrencyFormatNarrowSymbol
|
|
)
|
|
|
|
// CurrencyOption configures option.
|
|
type CurrencyOption func(*Currency)
|
|
|
|
// WithCurrencyFormat sets format currency.
|
|
func WithCurrencyFormat(format FormatCurrency) CurrencyOption {
|
|
return func(c *Currency) { c.Format = format }
|
|
}
|
|
|
|
// WithCurrencyISO sets ISO 4217 code currecy.
|
|
func WithCurrencyISO(iso string) CurrencyOption {
|
|
return func(c *Currency) { c.ISO = iso }
|
|
}
|
|
|
|
// Currency argument.
|
|
type Currency struct {
|
|
Key string
|
|
Value interface{}
|
|
Format FormatCurrency
|
|
// ISO 3-letter ISO 4217
|
|
ISO string
|
|
}
|
|
|
|
// String gets string from currency.
|
|
func (a Currency) String() string {
|
|
return fmt.Sprintf("currency key:%s, value:%v", a.Key, a.Value)
|
|
}
|
|
|
|
// Val gets value currency.
|
|
func (a Currency) Val() interface{} {
|
|
return a.Value
|
|
}
|
|
|