You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
708 B
34 lines
708 B
6 months ago
|
package util
|
||
|
|
||
|
import (
|
||
|
"math/rand"
|
||
|
"strconv"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
Filler = "0000000000"
|
||
|
)
|
||
|
|
||
|
func GetRandomString(l int) string {
|
||
|
str := "0123456789abcdefghijklmnopqrstuvwxyz"
|
||
|
bytes := []byte(str)
|
||
|
var result []byte
|
||
|
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||
|
for i := 0; i < l; i++ {
|
||
|
result = append(result, bytes[r.Intn(len(bytes))])
|
||
|
}
|
||
|
return string(result)
|
||
|
}
|
||
|
|
||
|
func MoneySmallestCurrency(amount float64, currency string) string {
|
||
|
var result string
|
||
|
switch currency {
|
||
|
case "USD", "PHP", "IDR", "THB", "HKD", "MYR", "CNY", "BDT", "PKR", "TWD", "JPY":
|
||
|
result = strconv.FormatFloat(amount*100, 'f', 0, 64)
|
||
|
case "KRW":
|
||
|
result = strconv.FormatFloat(amount, 'f', 0, 64)
|
||
|
}
|
||
|
return result
|
||
|
}
|