bytes2string

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 1 Imported by: 0

README

bytes2string

Go Report Card Go Reference License

Summary

Go module for converting int64 byte counts to a shortened SI, or IEC, string format. For example, 1000000 to '1.0 MB' or 1048576 to '1.0 MiB'.

Installation

go get github.com/jimrazmus/bytes2string

Usage

First, import the module.

import github.com/jimrazmus/bytes2string

Then, use the provided functions.

log.Println(ByteCountSI(12345678))

log.Println(ByteCountIEC(12345678))

Contributing

Please follow the Conventional Commits specification for your commit messages. Commit type options include: feat, fix, build, chore, ci, docs, style, refactor, perf, and test.

Open a pull request when you have completed your work and want it reviewed for inclusion.

Author

Functions originate here: https://yourbasic.org/golang/formatting-byte-size-to-human-readable-format/

Jim Razmus II - Minor modifications and formatting, along with adding testing and packaging.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

Documentation

Overview

Package bytes2string provides functions for converting int64 byte counts to a shortened SI, or IEC, string format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteCountIEC

func ByteCountIEC(bytes int64) string

ByteCountIEC returns a formatted string using the appropriate International Electrotechnical Commission prefix for any positive byte count or an empty string otherwise.

func ByteCountSI

func ByteCountSI(bytes int64) string

ByteCountSI returns a formatted string using the appropriate International System of Units prefix for any positive byte count or an empty string otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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