1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

doc: rename parameter name of Comma

This commit is contained in:
dudaodong
2024-09-27 10:23:29 +08:00
parent adf18a2e47
commit 30eb2c72b0
5 changed files with 9 additions and 9 deletions

View File

@@ -14,11 +14,11 @@ import (
"golang.org/x/exp/constraints"
)
// Comma add comma to a number value by every 3 numbers from right. ahead by symbol char.
// Comma add comma to a number value by every 3 numbers from right. ahead by prefix 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
func Comma[T constraints.Float | constraints.Integer | string](value T, symbol string) string {
func Comma[T constraints.Float | constraints.Integer | string](value T, prefixSymbol string) string {
numString := convertor.ToString(value)
_, err := strconv.ParseFloat(numString, 64)
@@ -45,7 +45,7 @@ func Comma[T constraints.Float | constraints.Integer | string](value T, symbol s
numString = "-" + numString
}
return symbol + numString
return prefixSymbol + numString
}
// Pretty data to JSON string.