Tags: Rhymond/go-money
Tags
GH-44 implement driver.Valuer and sql.Scanner for Amount and Currency (… …#99) * GH-44 implement driver.Valuer and sql.Scanner for money.Currency This allows any Golang ORM which supports the sql.Scanner to serialize (via sql.Driver) and deserialize (via sql.Scanner) a money.Currency instance. money.Amount is now a type alias to int64 which is already supported by sql.Scanner as one of the core built-in data types * GH-44 implement driver.Value and sql.Scanner for money.Money Money's Value() function enables compatible sql drivers to serialize a money.Money instance to a single comma-delimited string value of "amount,currency_code" Money's Scan() function assumes that it receives a single column where the src value is a comma- delimited string in the format "amount,currency_code" While the storage format is up to the client when the amount and currency are stored separately a compatible scanner value can be created in SQLite like this: SELECT amount || "," || currency as 'amount' It is left to the client to decide to use Money's Valuer implementation with a db annotation on a property of type Money or else to store the Amount and Currency values as two separate columns and return them as a single joined string field. * GH-44 fix an edge case strings.Split(src,,) will return a slice with length 2 even if one of the strings is empty * fix: money.value tests * refactor out the currency separator and make it customizable clients can set money.DBMoneyValueSeparator to determine which separator (e.g. "," "|" ";" ":" "AS" etc) to use when creating a single driver.Value object to represent a money.Money instance as a single string database field. this allows the money package to support string values such as 10@USD 20;CAD 30|IRD 40 in GBP etc --------- Co-authored-by: Raymond <[email protected]>
Add XOF and MGA currencies (#110) This patch adds West African CFA franc (XOF) and Malagasy ariary (MGA) currencies in order to provide them in go-money library. See also: - [West African CFA franc](https://en.wikipedia.org/wiki/West_African_CFA_franc); - [Malagasy ariary](https://en.wikipedia.org/wiki/Malagasy_ariary); Closes #109 Signed-off-by: r1cm3d <[email protected]>
PreviousNext