mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
improve StrToSize function for package gfile
This commit is contained in:
@ -68,6 +68,7 @@ We currently accept donation by Alipay/WechatPay, please note your github/gitee
|
||||
|金毛|alipay|¥100.00|
|
||||
|1*1x|wechat|¥100.00|
|
||||
|[ywanbing](https://github.com/ywanbing)|wechat|¥66.66|
|
||||
|[侯哥](http://www.macnie.com)|wechat|¥10.00|
|
||||
|
||||
|
||||
<img src="https://goframe.org/images/donate.png"/>
|
||||
|
||||
@ -47,21 +47,21 @@ func StrToSize(sizeStr string) int64 {
|
||||
switch strings.ToLower(unit) {
|
||||
case "b", "bytes":
|
||||
return int64(number)
|
||||
case "k", "kb", "kib", "kilobyte":
|
||||
case "k", "kb", "ki", "kib", "kilobyte":
|
||||
return int64(number * 1024)
|
||||
case "m", "mb", "mib", "mebibyte":
|
||||
case "m", "mb", "mi", "mib", "mebibyte":
|
||||
return int64(number * 1024 * 1024)
|
||||
case "g", "gb", "gib", "gigabyte":
|
||||
case "g", "gb", "gi", "gib", "gigabyte":
|
||||
return int64(number * 1024 * 1024 * 1024)
|
||||
case "t", "tb", "tib", "terabyte":
|
||||
case "t", "tb", "ti", "tib", "terabyte":
|
||||
return int64(number * 1024 * 1024 * 1024 * 1024)
|
||||
case "p", "pb", "pib", "petabyte":
|
||||
case "p", "pb", "pi", "pib", "petabyte":
|
||||
return int64(number * 1024 * 1024 * 1024 * 1024 * 1024)
|
||||
case "e", "eb", "eib", "exabyte":
|
||||
case "e", "eb", "ei", "eib", "exabyte":
|
||||
return int64(number * 1024 * 1024 * 1024 * 1024 * 1024 * 1024)
|
||||
case "z", "zb", "zib", "zettabyte":
|
||||
case "z", "zb", "zi", "zib", "zettabyte":
|
||||
return int64(number * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024)
|
||||
case "y", "yb", "yib", "yottabyte":
|
||||
case "y", "yb", "yi", "yib", "yottabyte":
|
||||
return int64(number * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024)
|
||||
case "bb", "brontobyte":
|
||||
return int64(number * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024)
|
||||
|
||||
@ -18,7 +18,6 @@ import (
|
||||
)
|
||||
|
||||
func Test_Rotate_Size(t *testing.T) {
|
||||
t.Parallel()
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
p := gfile.Join(gfile.TempDir(), gtime.TimestampNanoStr())
|
||||
@ -57,7 +56,6 @@ func Test_Rotate_Size(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Rotate_Expire(t *testing.T) {
|
||||
t.Parallel()
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
l := glog.New()
|
||||
p := gfile.Join(gfile.TempDir(), gtime.TimestampNanoStr())
|
||||
|
||||
Reference in New Issue
Block a user