1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Vendoring dependencies

This commit is contained in:
Chris Cummer
2019-07-15 09:06:49 -07:00
parent 122ea31e45
commit 2b19ccea1c
1980 changed files with 805966 additions and 0 deletions

14
vendor/github.com/hekmon/cunits/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,14 @@
# Binaries for programs and plugins
*.exe
*.dll
*.so
*.dylib
# Test binary, build with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/

21
vendor/github.com/hekmon/cunits/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Edouard Hur
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

60
vendor/github.com/hekmon/cunits/README.md generated vendored Normal file
View File

@@ -0,0 +1,60 @@
# ComputerUnits
[![GoDoc](https://godoc.org/github.com/hekmon/cunits?status.svg)](https://godoc.org/github.com/hekmon/cunits)
ComputerUnits allows to manipulate binary and decimal representations of bits and bytes.
## Constants example
```golang
fmt.Println(cunits.Kbit)
fmt.Println(cunits.Kibit)
fmt.Println(cunits.KB)
fmt.Println(cunits.KiB)
fmt.Printf("1000 MiB = %f MB\n", float64(1000)*cunits.MiB/cunits.MB)
```
will output:
```
1000
1024
8000
8192
1000 MiB = 1048.576000 MB
```
## Custom type example
```golang
size := cunits.Bit(58) * cunits.MiB
fmt.Println(size.Mbit())
fmt.Println(size.GiBString())
```
will output:
```
486.539264
0.06 GiB
```
## Parsing example
```golang
size, err := cunits.Parse("7632 MiB")
if err != nil {
panic(err)
}
fmt.Println(size)
fmt.Println(size.KiB())
fmt.Println(size.KbitString())
```
will output:
```
7.45 GiB
7.815168e+06
64021856.26 Kbit
```

424
vendor/github.com/hekmon/cunits/bits.go generated vendored Normal file
View File

@@ -0,0 +1,424 @@
package cunits
import "fmt"
// Bits represent a size in bits
type Bits uint64
// String allows direct reprensetation of Bit by calling GetHumanSizeRepresentation()
func (size Bits) String() string {
return size.GetHumanSizeRepresentation()
}
// GetHumanSizeRepresentation returns the size in a human readable binary prefix of bytes format
func (size Bits) GetHumanSizeRepresentation() string {
// if size >= YiB {
// return size.YiBString()
// }
// if size >= ZiB {
// return size.ZiBString()
// }
if size >= EiB {
return size.EiBString()
}
if size >= PiB {
return size.PiBString()
}
if size >= TiB {
return size.TiBString()
}
if size >= GiB {
return size.GiBString()
}
if size >= MiB {
return size.MiBString()
}
if size >= KiB {
return size.KiBString()
}
return size.ByteString()
}
// GetHumanSpeedRepresentation returns the size in a human readable decimal prefix of bits format
func (size Bits) GetHumanSpeedRepresentation() string {
// if size >= Ybit {
// return size.YbitString()
// }
// if size >= Zbit {
// return size.ZbitString()
// }
if size >= Ebit {
return size.EbitString()
}
if size >= Pbit {
return size.PbitString()
}
if size >= Tbit {
return size.TbitString()
}
if size >= Gbit {
return size.GbitString()
}
if size >= Mbit {
return size.MbitString()
}
if size >= Kbit {
return size.KbitString()
}
return size.BitString()
}
/*
Base forms
*/
// BitString returns the size in bit with unit suffix
func (size Bits) BitString() string {
return fmt.Sprintf("%d b", size)
}
// Byte returns the size in byte
func (size Bits) Byte() float64 {
return float64(size) / 8
}
// ByteString returns the size in byte with unit suffix
func (size Bits) ByteString() string {
return fmt.Sprintf("%.2f B", size.Byte())
}
/*
Decimal prefix of Bit
*/
// Kbit returns the size in kilobit
func (size Bits) Kbit() float64 {
return float64(size) / Kbit
}
// KbitString returns the size in kilobit with unit suffix
func (size Bits) KbitString() string {
return fmt.Sprintf("%.2f Kb", size.Kbit())
}
// Mbit returns the size in megabit
func (size Bits) Mbit() float64 {
return float64(size) / Mbit
}
// MbitString returns the size in megabit with unit suffix
func (size Bits) MbitString() string {
return fmt.Sprintf("%.2f Mb", size.Mbit())
}
// Gbit returns the size in gigabit
func (size Bits) Gbit() float64 {
return float64(size) / Gbit
}
// GbitString returns the size in gigabit with unit suffix
func (size Bits) GbitString() string {
return fmt.Sprintf("%.2f Gb", size.Gbit())
}
// Tbit returns the size in terabit
func (size Bits) Tbit() float64 {
return float64(size) / Tbit
}
// TbitString returns the size in terabit with unit suffix
func (size Bits) TbitString() string {
return fmt.Sprintf("%.2f Tb", size.Tbit())
}
// Pbit returns the size in petabit
func (size Bits) Pbit() float64 {
return float64(size) / Pbit
}
// PbitString returns the size in petabit with unit suffix
func (size Bits) PbitString() string {
return fmt.Sprintf("%.2f Pb", size.Pbit())
}
// Ebit returns the size in exabit
func (size Bits) Ebit() float64 {
return float64(size) / Ebit
}
// EbitString returns the size in exabit with unit suffix
func (size Bits) EbitString() string {
return fmt.Sprintf("%.2f Eb", size.Ebit())
}
// Zbit returns the size in zettabit
func (size Bits) Zbit() float64 {
return float64(size) / Zbit
}
// ZbitString returns the size in zettabit with unit suffix (carefull with sub zeros !)
func (size Bits) ZbitString() string {
return fmt.Sprintf("%f Zb", size.Zbit())
}
// Ybit returns the size in yottabit
func (size Bits) Ybit() float64 {
return float64(size) / Ybit
}
// YbitString returns the size in yottabit with unit suffix (carefull with sub zeros !)
func (size Bits) YbitString() string {
return fmt.Sprintf("%f Yb", size.Ybit())
}
/*
Binary prefix of Bit
*/
// Kibit returns the size in kibibit
func (size Bits) Kibit() float64 {
return float64(size) / Kibit
}
// KibitString returns the size in kibibit with unit suffix
func (size Bits) KibitString() string {
return fmt.Sprintf("%.2f Kib", size.Kibit())
}
// Mibit returns the size in mebibit
func (size Bits) Mibit() float64 {
return float64(size) / Mibit
}
// MibitString returns the size in mebibit with unit suffix
func (size Bits) MibitString() string {
return fmt.Sprintf("%.2f Mib", size.Mibit())
}
// Gibit returns the size in gibibit
func (size Bits) Gibit() float64 {
return float64(size) / Gibit
}
// GibitString returns the size in gibibit with unit suffix
func (size Bits) GibitString() string {
return fmt.Sprintf("%.2f Gib", size.Gibit())
}
// Tibit returns the size in tebibit
func (size Bits) Tibit() float64 {
return float64(size) / Tibit
}
// TibitString returns the size in tebibit with unit suffix
func (size Bits) TibitString() string {
return fmt.Sprintf("%.2f Tib", size.Tibit())
}
// Pibit returns the size in pebibit
func (size Bits) Pibit() float64 {
return float64(size) / Pibit
}
// PibitString returns the size in pebibit with unit suffix
func (size Bits) PibitString() string {
return fmt.Sprintf("%.2f Pib", size.Pibit())
}
// Eibit returns the size in exbibit
func (size Bits) Eibit() float64 {
return float64(size) / Eibit
}
// EibitString returns the size in exbibit with unit suffix
func (size Bits) EibitString() string {
return fmt.Sprintf("%.2f Eib", size.Eibit())
}
// Zibit returns the size in zebibit
func (size Bits) Zibit() float64 {
return float64(size) / Zibit
}
// ZibitString returns the size in zebibit with unit suffix (carefull with sub zeros !)
func (size Bits) ZibitString() string {
return fmt.Sprintf("%f Zib", size.Zibit())
}
// Yibit returns the size in yobibit
func (size Bits) Yibit() float64 {
return float64(size) / Yibit
}
// YibitString returns the size in yobibit with unit suffix (carefull with sub zeros !)
func (size Bits) YibitString() string {
return fmt.Sprintf("%f Yib", size.Yibit())
}
/*
Decimal prefix of bytes
*/
// KB returns the size in kilobyte
func (size Bits) KB() float64 {
return float64(size) / KB
}
// KBString returns the size in kilobyte with unit suffix
func (size Bits) KBString() string {
return fmt.Sprintf("%.2f KB", size.KB())
}
// MB returns the size in megabyte
func (size Bits) MB() float64 {
return float64(size) / MB
}
// MBString returns the size in megabyte with unit suffix
func (size Bits) MBString() string {
return fmt.Sprintf("%.2f MB", size.MB())
}
// GB returns the size in gigabyte
func (size Bits) GB() float64 {
return float64(size) / GB
}
// GBString returns the size in gigabyte with unit suffix
func (size Bits) GBString() string {
return fmt.Sprintf("%.2f GB", size.GB())
}
// TB returns the size in terabyte
func (size Bits) TB() float64 {
return float64(size) / TB
}
// TBString returns the size in terabyte with unit suffix
func (size Bits) TBString() string {
return fmt.Sprintf("%.2f TB", size.TB())
}
// PB returns the size in petabyte
func (size Bits) PB() float64 {
return float64(size) / PB
}
// PBString returns the size in petabyte with unit suffix
func (size Bits) PBString() string {
return fmt.Sprintf("%.2f PB", size.PB())
}
// EB returns the size in exabyte
func (size Bits) EB() float64 {
return float64(size) / EB
}
// EBString returns the size in exabyte with unit suffix
func (size Bits) EBString() string {
return fmt.Sprintf("%.2f EB", size.EB())
}
// ZB returns the size in zettabyte
func (size Bits) ZB() float64 {
return float64(size) / ZB
}
// ZBString returns the size in zettabyte with unit suffix (carefull with sub zeros !)
func (size Bits) ZBString() string {
return fmt.Sprintf("%f ZB", size.ZB())
}
// YB returns the size in yottabyte
func (size Bits) YB() float64 {
return float64(size) / YB
}
// YBString returns the size in yottabyte with unit suffix (carefull with sub zeros !)
func (size Bits) YBString() string {
return fmt.Sprintf("%f YB", size.YB())
}
/*
Binary prefix of bytes
*/
// KiB returns the size in kibibyte
func (size Bits) KiB() float64 {
return float64(size) / KiB
}
// KiBString returns the size in kibibyte with unit suffix
func (size Bits) KiBString() string {
return fmt.Sprintf("%.2f KiB", size.KiB())
}
// MiB returns the size in mebibyte
func (size Bits) MiB() float64 {
return float64(size) / MiB
}
// MiBString returns the size in mebibyte with unit suffix
func (size Bits) MiBString() string {
return fmt.Sprintf("%.2f MiB", size.MiB())
}
// GiB returns the size in gibibyte
func (size Bits) GiB() float64 {
return float64(size) / GiB
}
// GiBString returns the size in gibibyte with unit suffix
func (size Bits) GiBString() string {
return fmt.Sprintf("%.2f GiB", size.GiB())
}
// TiB returns the size in tebibyte
func (size Bits) TiB() float64 {
return float64(size) / TiB
}
// TiBString returns the size in tebibyte wit unit suffix
func (size Bits) TiBString() string {
return fmt.Sprintf("%.2f TiB", size.TiB())
}
// PiB returns the size in pebibyte
func (size Bits) PiB() float64 {
return float64(size) / PiB
}
// PiBString returns the size in pebibyte with unit suffix
func (size Bits) PiBString() string {
return fmt.Sprintf("%.2f PiB", size.PiB())
}
// EiB returns the size in exbibyte
func (size Bits) EiB() float64 {
return float64(size) / EiB
}
// EiBString returns the size in exbibyte with unit suffix (carefull with sub zeros !)
func (size Bits) EiBString() string {
return fmt.Sprintf("%f EiB", size.EiB())
}
// ZiB returns the size in zebibyte
func (size Bits) ZiB() float64 {
return float64(size) / ZiB
}
// ZiBString returns the size in zebibyte with unit suffix (carefull with sub zeros !)
func (size Bits) ZiBString() string {
return fmt.Sprintf("%f ZiB", size.ZiB())
}
// YiB returns the size in yobibyte
func (size Bits) YiB() float64 {
return float64(size) / YiB
}
// YiBString returns the size in yobibyte with unit suffix (carefull with sub zeros !)
func (size Bits) YiBString() string {
return fmt.Sprintf("%f YiB", size.YiB())
}

84
vendor/github.com/hekmon/cunits/consts.go generated vendored Normal file
View File

@@ -0,0 +1,84 @@
package cunits
// Byte represent a byte
const Byte = 8
// Decimal prefix of bits
const (
// Kbit represents a kilobit
Kbit = 1000
// Mbit represents a megabit
Mbit = 1000000
// Gbit represents a gigabit
Gbit = 1000000000
// Tbit represents a terabit
Tbit = 1000000000000
// Pbit represents a petabit
Pbit = 1000000000000000
// Ebit represents an exabit
Ebit = 1000000000000000000
// Zbit represents a zettabit (overflows int64)
Zbit = 1000000000000000000000
// Ybit represents a yottabit (overflows int64)
Ybit = 1000000000000000000000000
)
// Binary prefix of bits
const (
// Kibit represents a kibibit
Kibit = 1 << 10
// Mibit represents a mebibit
Mibit = 1 << 20
// Gibit represents a gibibit
Gibit = 1 << 30
// Tibit represents a tebibit
Tibit = 1 << 40
// Pibit represents a pebibit
Pibit = 1 << 50
// Eibit represents an exbibit
Eibit = 1 << 60
// Zibit represents a zebibit (overflows int64)
Zibit = 1 << 70
// Yibit represents a yobibit (overflows int64)
Yibit = 1 << 80
)
// Decimal prefix of bytes
const (
// KB represents a kilobyte
KB = Kbit * Byte
// MB represents a megabyte
MB = Mbit * Byte
// GB represents a gigabyte
GB = Gbit * Byte
// TB represents a terabyte
TB = Tbit * Byte
// PB represents a petabyte
PB = Pbit * Byte
// EB represents an exabyte
EB = Ebit * Byte
// ZB represents a zettabyte (overflows int64)
ZB = Zbit * Byte
// YB represents a yottabyte (overflows int64)
YB = Ybit * Byte
)
// Binary prefix of bytes
const (
// KiB represents a kibibyte
KiB = Kibit * Byte
// MiB represents a mebibyte
MiB = Mibit * Byte
// GiB represents a gibibyte
GiB = Gibit * Byte
// TiB represents a tebibyte
TiB = Tibit * Byte
// PiB represents a pebibyte
PiB = Pibit * Byte
// EiB represents an exbibyte (overflows int64)
EiB = Eibit * Byte
// ZiB represents a zebibyte (overflows int64)
ZiB = Zbit * Byte
// YiB represents a yobibyte (overflows int64)
YiB = Ybit * Byte
)

292
vendor/github.com/hekmon/cunits/import.go generated vendored Normal file
View File

@@ -0,0 +1,292 @@
package cunits
import (
"fmt"
"regexp"
"strconv"
"strings"
)
const parseRegex = "^([0-9,]+(\\.[0-9]+)?) ?(([KMGTPEZY]i?)?(B|bit))$"
var sizeMatch = regexp.MustCompile(parseRegex)
// Parse parses un string representation of a number with a suffix
func Parse(sizeSuffix string) (size Bits, err error) {
// Does it match ?
match := sizeMatch.FindSubmatch([]byte(sizeSuffix))
if match == nil {
err = fmt.Errorf("string does not match the parsing regex: %s", parseRegex)
return
}
if len(match) < 4 {
err = fmt.Errorf("regex matching did not return enough groups")
return
}
// Extract number
num, err := strconv.ParseFloat(strings.Replace(string(match[1]), ",", "", -1), 64)
if err != nil {
err = fmt.Errorf("extracted number '%s' can't be parsed as float64: %v", string(match[1]), err)
return
}
// Findout the unit
switch string(match[3]) {
case "bit":
size = Bits(num)
case "B":
size = ImportInByte(num)
// Decimal prefix of bits
case "Kbit":
size = ImportInKbit(num)
case "Mbit":
size = ImportInMbit(num)
case "Gbit":
size = ImportInGbit(num)
case "Tbit":
size = ImportInTbit(num)
case "Pbit":
size = ImportInPbit(num)
case "Ebit":
size = ImportInEbit(num)
case "Zbit":
size = ImportInZbit(num)
case "Ybit":
size = ImportInYbit(num)
// Binary prefix of bits
case "Kibit":
size = ImportInKibit(num)
case "Mibit":
size = ImportInMibit(num)
case "Gibit":
size = ImportInGibit(num)
case "Tibit":
size = ImportInTibit(num)
case "Pibit":
size = ImportInPibit(num)
case "Eibit":
size = ImportInEibit(num)
case "Zibit":
size = ImportInZibit(num)
case "Yibit":
size = ImportInYibit(num)
// Decimal prefix of bytes
case "KB":
size = ImportInKB(num)
case "MB":
size = ImportInMB(num)
case "GB":
size = ImportInGB(num)
case "TB":
size = ImportInTB(num)
case "PB":
size = ImportInPB(num)
case "EB":
size = ImportInEB(num)
case "ZB":
size = ImportInZB(num)
case "YB":
size = ImportInYB(num)
// Binary prefix of bytes
case "KiB":
size = ImportInKiB(num)
case "MiB":
size = ImportInMiB(num)
case "GiB":
size = ImportInGiB(num)
case "TiB":
size = ImportInTiB(num)
case "PiB":
size = ImportInPiB(num)
case "EiB":
size = ImportInEiB(num)
case "ZiB":
size = ImportInZiB(num)
case "YiB":
size = ImportInYiB(num)
// or not
default:
err = fmt.Errorf("extracted unit '%s' is unknown", string(match[3]))
}
return
}
// ImportInByte imports a number in byte
func ImportInByte(sizeInByte float64) Bits {
return Bits(sizeInByte * Byte)
}
/*
Decimal prefix of bits
*/
// ImportInKbit imports a number in kilobit
func ImportInKbit(sizeInKbit float64) Bits {
return Bits(sizeInKbit * Kbit)
}
// ImportInMbit imports a number in megabit
func ImportInMbit(sizeInMbit float64) Bits {
return Bits(sizeInMbit * Mbit)
}
// ImportInGbit imports a number in gigabit
func ImportInGbit(sizeInGbit float64) Bits {
return Bits(sizeInGbit * Gbit)
}
// ImportInTbit imports a number in terabit
func ImportInTbit(sizeInTbit float64) Bits {
return Bits(sizeInTbit * Tbit)
}
// ImportInPbit imports a number in petabit
func ImportInPbit(sizeInPbit float64) Bits {
return Bits(sizeInPbit * Pbit)
}
// ImportInEbit imports a number in exabit
func ImportInEbit(sizeInEbit float64) Bits {
return Bits(sizeInEbit * Ebit)
}
// ImportInZbit imports a number in zettabit (sizeInZbit better < 1)
func ImportInZbit(sizeInZbit float64) Bits {
return Bits(sizeInZbit * Zbit)
}
// ImportInYbit imports a number in yottabit (sizeInYbit better < 1)
func ImportInYbit(sizeInYbit float64) Bits {
return Bits(sizeInYbit * Ybit)
}
/*
Binary prefix of bits
*/
// ImportInKibit imports a number in kibibit
func ImportInKibit(sizeInKibit float64) Bits {
return Bits(sizeInKibit * Kibit)
}
// ImportInMibit imports a number in mebibit
func ImportInMibit(sizeInMibit float64) Bits {
return Bits(sizeInMibit * Mibit)
}
// ImportInGibit imports a number in gibibit
func ImportInGibit(sizeInGibit float64) Bits {
return Bits(sizeInGibit * Gibit)
}
// ImportInTibit imports a number in tebibit
func ImportInTibit(sizeInTibit float64) Bits {
return Bits(sizeInTibit * Tibit)
}
// ImportInPibit imports a number in pebibit
func ImportInPibit(sizeInPibit float64) Bits {
return Bits(sizeInPibit * Pibit)
}
// ImportInEibit imports a number in exbibit
func ImportInEibit(sizeInEibit float64) Bits {
return Bits(sizeInEibit * Eibit)
}
// ImportInZibit imports a number in zebibit (sizeInZibit better < 1)
func ImportInZibit(sizeInZibit float64) Bits {
return Bits(sizeInZibit * Zibit)
}
// ImportInYibit imports a number in yobibit (sizeInYibit better < 1)
func ImportInYibit(sizeInYibit float64) Bits {
return Bits(sizeInYibit * Yibit)
}
/*
Decimal prefix of bytes
*/
// ImportInKB imports a number in kilobyte
func ImportInKB(sizeInKB float64) Bits {
return Bits(sizeInKB * KB)
}
// ImportInMB imports a number in megabyte
func ImportInMB(sizeInMB float64) Bits {
return Bits(sizeInMB * MB)
}
// ImportInGB imports a number in gigabyte
func ImportInGB(sizeInGB float64) Bits {
return Bits(sizeInGB * GB)
}
// ImportInTB imports a number in terabyte
func ImportInTB(sizeInTB float64) Bits {
return Bits(sizeInTB * TB)
}
// ImportInPB imports a number in petabyte
func ImportInPB(sizeInPB float64) Bits {
return Bits(sizeInPB * PB)
}
// ImportInEB imports a number in exabyte
func ImportInEB(sizeInEB float64) Bits {
return Bits(sizeInEB * EB)
}
// ImportInZB imports a number in zettabyte (sizeInZB better < 1)
func ImportInZB(sizeInZB float64) Bits {
return Bits(sizeInZB * ZB)
}
// ImportInYB imports a number in yottabyte (sizeInYB better < 1)
func ImportInYB(sizeInYB float64) Bits {
return Bits(sizeInYB * YB)
}
/*
Binary prefix of bytes
*/
// ImportInKiB imports a number in kilobyte
func ImportInKiB(sizeInKiB float64) Bits {
return Bits(sizeInKiB * KiB)
}
// ImportInMiB imports a number in megabyte
func ImportInMiB(sizeInMiB float64) Bits {
return Bits(sizeInMiB * MiB)
}
// ImportInGiB imports a number in gigabyte
func ImportInGiB(sizeInGiB float64) Bits {
return Bits(sizeInGiB * GiB)
}
// ImportInTiB imports a number in terabyte
func ImportInTiB(sizeInTiB float64) Bits {
return Bits(sizeInTiB * TiB)
}
// ImportInPiB imports a number in petabyte
func ImportInPiB(sizeInPiB float64) Bits {
return Bits(sizeInPiB * PiB)
}
// ImportInEiB imports a number in exabyte (sizeInEiB better < 1)
func ImportInEiB(sizeInEiB float64) Bits {
return Bits(sizeInEiB * EiB)
}
// ImportInZiB imports a number in zettabyte (sizeInZiB better < 1)
func ImportInZiB(sizeInZiB float64) Bits {
return Bits(sizeInZiB * ZiB)
}
// ImportInYiB imports a number in yottabyte (sizeInYiB better < 1)
func ImportInYiB(sizeInYiB float64) Bits {
return Bits(sizeInYiB * YiB)
}