Hi I'm working on a function to format values in currency. I'm using golang.org/x/text/currency for the job, but I'm getting the output with points at the place of commas and no thousands separators.
func (produto *Produto) FormataPreco(valor int64) string {
unit, _ := currency.ParseISO("BRL")
p := message.NewPrinter(language.BrazilianPortuguese)
return p.Sprint(currency.Symbol(unit.Amount(float64(valor) / 100)))
}
The expected result should be R$ 123.456,78 but I'm getting R$ 123456.78
--- Edit ---
I did a version using hardcoded values, but I would like a solution that uses system locale resources.
func (produto *Produto) FormataPreco(valor int64) string {
p := message.NewPrinter(language.BrazilianPortuguese)
return p.Sprintf("R$ %.2f", float64(valor/100))
}