Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NoopConverter ¶
type NoopConverter struct{}
NoopConverter assumes all currencies are the same and returns the input unchanged.
func NewNoopConverter ¶
func NewNoopConverter() *NoopConverter
NewNoopConverter returns a new NoopConverter instance.
type StaticConverter ¶
type StaticConverter struct {
// contains filtered or unexported fields
}
StaticConverter holds a static rate table for currency conversion. Rates are expressed in basis points: rate["USD"]["BRL"] = 50000 means 1 USD = 5.0000 BRL. The conversion formula is: (amountCents * rate) / 10000.
func NewStaticConverter ¶
func NewStaticConverter(rates map[string]map[string]int64) *StaticConverter
NewStaticConverter returns a new StaticConverter with the given rates.
func (*StaticConverter) Convert ¶
func (c *StaticConverter) Convert(ctx context.Context, amountCents int64, fromCurrency, toCurrency string) (int64, error)
Convert converts amountCents from fromCurrency to toCurrency using the static rate table. It uses integer arithmetic with a fixed precision of 4 decimal places (10000 divisor).
Click to show internal directories.
Click to hide internal directories.