Documentation ¶
Overview ¶
Copyright 2022 Michal Vyskocil. All rights reserved. Use of this source code is governed by a MIT license that can be found in the LICENSE file.
Index ¶
Constants ¶
const ( Block Byte = 512 // b KiloByte = 1000 // kB KibiByte = 1024 // K/KiB MegaByte = 1000 * KiloByte // MB MebiByte = 1024 * KibiByte // M/MiB GigaByte = 1000 * MegaByte // GB GibiByte = 1024 * MebiByte // G/GiB TeraByte = 1000 * GigaByte // TB TebiByte = 1024 * GibiByte // T/TiB PetaByte = 1000 * TeraByte // PB PebiByte = 1024 * TebiByte // P/PiB ExaByte = 1000 * PetaByte // ZB ExbiByte = 1024 * PebiByte // Z/ZiB ZettaByte = 1000 * ExaByte // ZB ZebiByte = 1024 * ExbiByte // Z/ZiB YottaByte = 1000 * ZettaByte // YB YobiByte = 1024 * ZebiByte // Y/YiB )
Byte may have a multiplier suffix: b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024, GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y. Binary prefixes can be used, too: KiB=K, MiB=M, and so on. see https://man7.org/linux/man-pages/man1/head.1.html
Variables ¶
var ( ErrEmpty = errors.New("empty") ErrInvalidNextCharacter = errors.New("expected number or decimal separator") ErrOverflow = errors.New("overflow") ErrNoDigits = errors.New("no digits") )
var ByteSuffixes = map[string]float64{ "b": float64(Block), "kB": float64(KiloByte), "K": float64(KibiByte), "KiB": float64(KibiByte), "MB": float64(MegaByte), "M": float64(MebiByte), "MiB": float64(MebiByte), "GB": float64(GigaByte), "G": float64(GibiByte), "GiB": float64(GibiByte), "TB": float64(TeraByte), "T": float64(TebiByte), "TiB": float64(TebiByte), "PB": float64(PetaByte), "P": float64(PebiByte), "PiB": float64(PebiByte), "EB": float64(ExaByte), "E": float64(ExbiByte), "EiB": float64(ExbiByte), "ZB": float64(ZettaByte), "Z": float64(ZebiByte), "ZiB": float64(ZebiByte), "YB": float64(YottaByte), "Y": float64(YobiByte), "YiB": float64(YobiByte), }
Functions ¶
Types ¶
type Byte ¶
type Byte Unit
Byte is a size of disk/memory/buffer capacities
func ParseByte ¶
ParseByte parses a byte definition. A byte string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300K", "-1.5MiB" or "1TB45GB". Valid time units are "b" block 512, "kB" kilobyte 1000, "K", "KiB" kibibyte 1024 and so on for M, G, T, P, E, Z, Y
type RunFiles ¶
type RunFiles struct {
// contains filtered or unexported fields
}
RunFiles is a helper run gonix commands with inputs from more files failure in file opening does not break the loop, but returns exit code 1 "" or "-" are treated as stdin