From 57baa307c4404fe9017d8242317228e138f5b0dd Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 21 May 2017 18:50:19 +0200 Subject: Comments --- format.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/format.go b/format.go index 3a4f21b..f9e689d 100644 --- a/format.go +++ b/format.go @@ -25,16 +25,17 @@ func fill(s string, n int) string { return s + strings.Repeat("0", n-len(s)) } +// Country settings type Country struct { - Thousend, Decimal rune - Block, Fraction int + Thousend, Decimal rune // delimiter rune + Block, Fraction int // block length } const ( - Space = '\u0020' - Apostrophe = '\u0027' - Comma = '\u002c' - FullStop = '\u002e' + Space = ' ' + Apostrophe = '\'' + Comma = ',' + FullStop = '.' MiddleDot = '\u00b7' ThinSpace = '\u2009' NoBreakSpace = '\u202f' @@ -49,11 +50,13 @@ var ( IR = Country{Space, MiddleDot, 3, 2} CH = Country{Apostrophe, FullStop, 3, 2} IT = Country{DotAbove, Comma, 3, 2} - CN = Country{Comma, FullStop, 4, 2} + CN = Country{Comma, FullStop, 4, 2} // 10000 based ) +// DefaultFormat is europeian SI format var DefaultFormat = FR +// Format float value as localized representation func (c Country) Format(v float64) string { s := strconv.FormatFloat(v, 'f', -1, 64) neg := strings.HasPrefix(s, "-") -- cgit v1.2.3