Skip to content
This repository was archived by the owner on Feb 25, 2023. It is now read-only.

things-go/meter

Repository files navigation

meter storage metering

storage metering,like B,KB,MB,GB,TB,PB,EB

GoDoc Go.Dev reference codecov Action Status Go Report Card License Tag

Features

  1. support human string like B,KB,MB,GB,TB,PB,EB
  2. 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

Installation

  1. You can use the below Go command to install meter.
    go get -u github.com/things-go/meter
  1. Import it in your code.
    import "github.com/things-go/meter"

Quick start

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
}

Reference

Donation

if package help you a lot,you can support us by:

Alipay

alipay

WeChat Pay

wxpay

About

storage metering,like B,KB,MB,GB,TB,PB,EB, use https://github.com/dustin/go-humanize instead.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages