I am trying to format some digits as a currency with commas and two decimal places. I found "github.com/dustin/go-humanize" for commas, but it does not allow you to specify the number of decimal places. fmt.Sprintf will do currency and decimal formatting, but not commas.
for _, fl := range []float64{123456.789, 123456.0, 123456.0100} {
log.Println(humanize.Commaf(fl))
}
Results:
123,456.789
123,456
123,456.01
I expect:
$123,456.79
$123,456.00
$123,456.01
user776942
source
share