mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
publish lancet
This commit is contained in:
1 parent
37edb0fc8f
commit
3254591ab9
38 files changed
+5163
No files matched your search
@@ -0,0 +1,17 @@
|
||||
// Copyright 2021 dudaodong@gmail.com. All rights reserved.
|
||||
// Use of this source code is governed by MIT license
|
||||
|
||||
// Package formatter implements some functions to format string, struct.
|
||||
package formatter
|
||||
|
||||
import "strings"
|
||||
|
||||
// Comma add comma to number by every 3 numbers from right. ahead by symbol char
|
||||
func Comma(v interface{}, symbol string) string {
|
||||
s := numString(v)
|
||||
dotIndex := strings.Index(s, ".")
|
||||
if dotIndex != -1 {
|
||||
return symbol + commaString(s[:dotIndex]) + s[dotIndex:]
|
||||
}
|
||||
return symbol + commaString(s)
|
||||
}
|
||||
Reference in new issue
Block a user