func Size(path string) int64
func ExampleSize() {
// init
var (
fileName = "gflie_example.txt"
tempDir = gfile.TempDir("gfile_example_size")
tempFile = gfile.Join(tempDir, fileName)
)
// write contents
gfile.PutContents(tempFile, "0123456789")
fmt.Println(gfile.Size(tempFile))
// Output:
// 10
}
func SizeFormat(path string) string
func ExampleSizeFormat() {
// init
var (
fileName = "gflie_example.txt"
tempDir = gfile.TempDir("gfile_example_size")
tempFile = gfile.Join(tempDir, fileName)
)
// write contents
gfile.PutContents(tempFile, "0123456789")
fmt.Println(gfile.SizeFormat(tempFile))
// Output:
// 10.00B
}
func ReadableSize(path string) string
func ExampleReadableSize() {
// init
var (
fileName = "gflie_example.txt"
tempDir = gfile.TempDir("gfile_example_size")
tempFile = gfile.Join(tempDir, fileName)
)
// write contents
gfile.PutContents(tempFile, "01234567899876543210")
fmt.Println(gfile.ReadableSize(tempFile))
// Output:
// 20.00B
}
func StrToSize(sizeStr string) int64
func ExampleStrToSize() {
size := gfile.StrToSize("100MB")
fmt.Println(size)
// Output:
// 104857600
}
func FormatSize(raw int64) string
func ExampleFormatSize() {
sizeStr := gfile.FormatSize(104857600)
fmt.Println(sizeStr)
sizeStr0 := gfile.FormatSize(1024)
fmt.Println(sizeStr0)
sizeStr1 := gfile.FormatSize(999999999999999999)
fmt.Println(sizeStr1)
// Output:
// 100.00M
// 1.00K
// 888.18P
}
备案信息: 粤ICP备15087711号-2
Copyright © 2008-2024 啊嘎哇在线工具箱 All Rights.
本站所有资料来源于网络,版权归原作者所有,仅作学习交流使用,如不慎侵犯了您的权利,请联系我们。