1临时提交 生成订单
Some checks failed
Build / build (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
build / Build (push) Has been cancelled
GitHub Actions Mirror / mirror_to_gitee (push) Has been cancelled
GitHub Actions Mirror / mirror_to_gitlab (push) Has been cancelled
Issue Close Require / issue-close-require (push) Has been cancelled
Some checks failed
Build / build (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
build / Build (push) Has been cancelled
GitHub Actions Mirror / mirror_to_gitee (push) Has been cancelled
GitHub Actions Mirror / mirror_to_gitlab (push) Has been cancelled
Issue Close Require / issue-close-require (push) Has been cancelled
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
package utility
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
// DesensitizeGeneric 通用脱敏函数:
|
||||
// startReserveCount: 从字符串开头保留的字符数
|
||||
@ -61,3 +65,14 @@ func DesensitizeGeneric(text string, startReserveCount int, endReserveCount int,
|
||||
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
func StringToDecimal(val string) decimal.Decimal {
|
||||
cleanedNum := strings.TrimRight(val, "\x00") // 去除空字符
|
||||
cleanedNum = strings.TrimSpace(cleanedNum) // 去除空格
|
||||
cleanedNum = strings.ReplaceAll(cleanedNum, ",", "") // 去除逗号
|
||||
d, err := decimal.NewFromString(cleanedNum)
|
||||
if err != nil {
|
||||
return decimal.Zero
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user