dataSizeKit

package
v2.1.51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B   uint64 = 1
	KiB uint64 = 1 << 10
	MiB uint64 = 1 << 20
	GiB uint64 = 1 << 30
	TiB uint64 = 1 << 40
	PiB uint64 = 1 << 50
	EiB uint64 = 1 << 60
)

Variables

View Source
var ParseString func(str string) (uint64, error) = humanize.ParseBytes

ParseString

@param str 同时支持"IEC标准"和"SI标准" @return 第一个返回值的单位: 字节(bytes)

e.g. ("42MB") => 42000000 <nil> ("42 MB") => 42000000 <nil> ("42mib") => 44040192 <nil> ("42 mib") => 44040192 <nil>

View Source
var ToReadableStringWithIEC func(s uint64) string = humanize.IBytes

ToReadableStringWithIEC

PS: (1) 采用IEC标准(国际电工委员会;https://blog.csdn.net/bioitee/article/details/120797739). (2) 1KB == 1024 (3) 采用此标准: Windows的文件资源管理器、钉钉(Mac版和Windows版都是)、XManager和Tabby的可视化工具...

@param s 单位: 字节(bytes)

e.g.

(78848) => "77 KiB"
View Source
var ToReadableStringWithSI func(s uint64) string = humanize.Bytes

ToReadableStringWithSI

PS: (1) 采用SI标准(国际单位制;https://blog.csdn.net/bioitee/article/details/120797739). (2) 1KB == 1000 (3) 采用此标准: Mac的访达...

@param s 单位: 字节(bytes)

e.g.

(78848) => "79 kB"

Functions

func ByteToGiB added in v2.1.32

func ByteToGiB(bytes uint64) float64

ByteToGiB

PS: IEC标准.

func ByteToMiB added in v2.1.32

func ByteToMiB(bytes uint64) float64

ByteToMiB

PS: IEC标准.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL