Documentation ¶
Overview ¶
Package formatter implements some functions to format string, struct.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Comma ¶
func Comma[T constraints.Float | constraints.Integer | string](value T, symbol string) string
Comma add comma to a number value by every 3 numbers from right. ahead by symbol char. if value is invalid number string eg "aa", return empty string Comma("12345", "$") => "$12,345", Comma(12345, "$") => "$12,345" Play: https://go.dev/play/p/eRD5k2vzUVX
Example ¶
result1 := Comma("123", "") result2 := Comma("12345", "$") result3 := Comma(1234567, "¥") fmt.Println(result1) fmt.Println(result2) fmt.Println(result3)
Output: 123 $12,345 ¥1,234,567
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.