storage metering,like B,KB,MB,GB,TB,PB,EB
- support human string like B,KB,MB,GB,TB,PB,EB
- support parse string unit below:
- "empty",b,byte,
- k,kb,kilo,kilobyte
- m,mb,mega,megabyte,megabytes
- g,gb,giga,gigabyte,gigabytes
- t,tb,tera,terabyte,terabytes
- p,pb,peta,petabyte,petabytes
- e,eb,exa,exabyte,exabytes
- You can use the below Go command to install meter.
go get -u github.com/things-go/meter
- Import it in your code.
import "github.com/things-go/meter"
package main
import (
"fmt"
"github.com/things-go/meter"
)
func main() {
value, _ := meter.ParseBytes("2.99TB")
s := meter.HumanSize(value)
fmt.Println(value)
fmt.Println(s)
// output:
// 3287539767050
// 2.99TB
}
if package help you a lot,you can support us by:
Alipay
WeChat Pay