Documentation ¶
Overview ¶
Example (ByteSize) ¶
package main import ( "bytes" "github.com/adamluzsi/frameless/pkg/units" "io" ) func main() { var bs = make([]byte, units.Megabyte) buf := &bytes.Buffer{} n, err := buf.Write(bs) if err != nil { panic(err.Error()) } if n < units.Kilobyte { // } io.LimitReader(buf, 128*units.Kibibyte) }
Output:
Index ¶
Examples ¶
Constants ¶
const ( Byte = 1 << (10 * iota) // ignore first value by assigning to blank identifier Kibibyte Mebibyte Gibibyte Tebibyte Pebibyte )
const ( Kilobyte = Kibibyte Megabyte = Mebibyte Gigabyte = Gibibyte Terabyte = Tebibyte )
Variables ¶
This section is empty.
Functions ¶
func FormatByteSize ¶
FormatByteSize will format byte size interpreted as the unit of digital information. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable unit of memory in many computer architectures
| Value | IEC | Memory | |-------|--------------|--------------| | 1 | B byte | B byte | | 1024 | KiB kibibyte | KB kilobyte | | 10242 | MiB mebibyte | MB megabyte | | 10243 | GiB gibibyte | GB gigabyte | | 10244 | TiB tebibyte | TB terabyte | | 10245 | PiB pebibyte | – | | 10246 | EiB exbibyte | – | | 10247 | ZiB zebibyte | – | | 10248 | YiB yobibyte | – |
Types ¶
This section is empty.