go-humanize
go-humanize copied to clipboard
Allow to skip trailing zeros in FormatFloat
I like to format 123.123
and 123.1234
to with "up to 4" digits after the comma.
But using the format #.####
would result in 123.1230
for the first case instead of 123.123
Could we have something like #,####
= fill trailing zeros and #,****
skip trailing zeros? That would be backwards compatible. Or is there any formatting guideline that you are following?
As far as i know there is no direct way of doing this, what you can do is
strings.TrimRight(strings.TrimRight(humanize.FormatFloat("", 123.1), "0"), ".")