Option for thousands separator
mariusgrigoriu opened this issue · 4 comments
It seems like it would be a good idea to have an option for a thousands separator for floats and ints, which can make structs with many large numbers easier to read. For example:
myStruct{
myfloat: 1,000,000.00,
}
What do you think?
How about 1_000_000.00
instead? It seems like the literal was added in Go 1.13, so the format could be useful to keep it valid as a Go literal.
Also, do you have any idea about the option name? WDYT about:
mypp = pp.New()
mypp.SetNumberDelimiter(true)
mypp.Println(...)
Let's reopen this when we get attention on this again.
The term encountered most often with other applications seems to be thousands separator. Would that make it:
mypp = pp.New()
mypp.SetThousandsSeparator(true)
mypp.Println(...)
Is the idea that the output from pp can be pasted as Go code? If so the underscores probably makes sense. If legibility is the primary concern, what if we take a character instead of a bool like so:
mypp = pp.New()
mypp.SetThousandsSeparator(",")
mypp.Println(...)
That way people can use whatever value suits them. Or perhaps let golang.org/x/text/messages
handle the localization?
SetThousandsSeparator
looks good to me. I'm also okay with ","
instead of true
, but if you don't intend to allow everything there, another option could be to use ','
.
It seems like we have a plan now. Would you be interested in adding it? We recently added some other options #55 #60, which might help you prepare it.