bytesize

package module
v0.0.0-...-a04bb4d Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: MIT Imports: 0 Imported by: 0

README

bytesize

bytesize provides simple byte unit constants. These include decimal units (kilobyte, megabyte) and binary units (kibibyte, mebibyte).

This is useful wherever you may need to provide a number of bytes, helping with readability. For example:

func myHandler(w http.ResponseWriter, r *http.Request) {
    limitedReq := io.LimitReader(r.Body, 3 * bytesize.Kilobyte)

	data, err := io.ReadAll(limitedReq)
	if err != nil {
		...
	}
    ...
}

Documentation

Index

Constants

View Source
const (
	Kibibyte int64 = 1 << ((iota + 1) * 10)
	Mebibyte
	Gibibyte
	Tebibyte
	Pebibyte
	Exbibyte
)
View Source
const (
	Kilobyte int64 = 1000
	Megabyte       = 1000 * Kilobyte
	Gigabyte       = 1000 * Megabyte
	Terabyte       = 1000 * Gigabyte
	Petabyte       = 1000 * Terabyte
	Exabyte        = 1000 * Petabyte
)

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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