pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/zpatrick/go-bytesize

github.githubassets.com/assets/primer-70be7debc79a8eff.css" /> GitHub - zpatrick/go-bytesize: Utility package for working with common memory and cpu units in Go · GitHub
Skip to content

zpatrick/go-bytesize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Go Bytesize

MIT License Go Report Card Go Doc

Overview

Go Bytesize is a utility package for working with common multiples of bytes in Go, such as: Bytes (B), Kilobytes (KB), Megabytes (MB), Gigabytes (GB), Terabytes (TB), Petabytes (PB), Exabytes (EB), Kibibytes (Kib), Mebibytes (MiB), Gibibytes (GiB), Tebibytes (TiB), Pebibytes (PiB), and Exbibytes (EiB).

Example

package main

import (
        "fmt"
        "github.com/zpatrick/go-bytesize"
)

func main() {
        b := bytesize.Bytesize(10000)
        fmt.Printf("%g bytes is: %g KB and %g MB\n", b, b.Kilobytes(), b.Megabytes())

        b = bytesize.TB * 2
        fmt.Printf("2 Terabytes is %g Gibibytes\n", b.Gibibytes())

        b = bytesize.Bytesize(1000000)
        fmt.Printf("%g bytes is %s\n", b, b.Format("mb"))
}

Output:

10000 bytes is: 10 KB and 0.01 MB
2 Terabytes is 1862.645149230957 Gibibytes
1e+06 bytes is 1MB

License

This work is published under the MIT license. Please see the LICENSE file for details.

About

Utility package for working with common memory and cpu units in Go

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy