summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-bytesize
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2022-12-27 08:28:44 +0000
committerLibravatar GitHub <noreply@github.com>2022-12-27 08:28:44 +0000
commitabd594b71f36c4a48ec1d9ea737cdd3feb63f32d (patch)
tree556522f7b64b7b7909bc7dd745c741b86866fbb7 /vendor/codeberg.org/gruf/go-bytesize
parent[feature] For video attachments, store + return fps, bitrate, duration (#1282) (diff)
downloadgotosocial-abd594b71f36c4a48ec1d9ea737cdd3feb63f32d.tar.xz
[chore]: Bump codeberg.org/gruf/go-bytesize from 1.0.0 to 1.0.2 (#1285)
Bumps codeberg.org/gruf/go-bytesize from 1.0.0 to 1.0.2. --- updated-dependencies: - dependency-name: codeberg.org/gruf/go-bytesize dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-bytesize')
-rw-r--r--vendor/codeberg.org/gruf/go-bytesize/README.md2
-rw-r--r--vendor/codeberg.org/gruf/go-bytesize/bytesize.go37
2 files changed, 19 insertions, 20 deletions
diff --git a/vendor/codeberg.org/gruf/go-bytesize/README.md b/vendor/codeberg.org/gruf/go-bytesize/README.md
index 46a0457ca..00ef52550 100644
--- a/vendor/codeberg.org/gruf/go-bytesize/README.md
+++ b/vendor/codeberg.org/gruf/go-bytesize/README.md
@@ -1,3 +1 @@
Byte size formatting and parsing.
-
-todo: more robust tests \ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-bytesize/bytesize.go b/vendor/codeberg.org/gruf/go-bytesize/bytesize.go
index 4426107bd..939397939 100644
--- a/vendor/codeberg.org/gruf/go-bytesize/bytesize.go
+++ b/vendor/codeberg.org/gruf/go-bytesize/bytesize.go
@@ -3,6 +3,7 @@ package bytesize
import (
"errors"
"math/bits"
+ _ "strconv"
"unsafe"
)
@@ -52,18 +53,18 @@ var (
}
// bvals is a precomputed table of IEC unit values.
- iecvals = [...]Size{
- 'k': KiB,
- 'K': KiB,
- 'M': MiB,
- 'G': GiB,
- 'T': TiB,
- 'P': PiB,
- 'E': EiB,
+ iecvals = [...]float64{
+ 'k': float64(KiB),
+ 'K': float64(KiB),
+ 'M': float64(MiB),
+ 'G': float64(GiB),
+ 'T': float64(TiB),
+ 'P': float64(PiB),
+ 'E': float64(EiB),
}
// sivals is a precomputed table of SI unit values.
- sivals = [...]Size{
+ sivals = [...]float64{
// ASCII numbers _aren't_ valid SI unit values,
// BUT if the space containing a possible unit
// char is checked with this table -- it is valid
@@ -79,13 +80,13 @@ var (
'8': 1,
'9': 1,
- 'k': KB,
- 'K': KB,
- 'M': MB,
- 'G': GB,
- 'T': TB,
- 'P': PB,
- 'E': EB,
+ 'k': float64(KB),
+ 'K': float64(KB),
+ 'M': float64(MB),
+ 'G': float64(GB),
+ 'T': float64(TB),
+ 'P': float64(PB),
+ 'E': float64(EB),
}
)
@@ -107,7 +108,7 @@ func ParseSize(s string) (Size, error) {
return 0, ErrInvalidFormat
}
- return Size(f) * unit, nil
+ return Size(f * unit), nil
}
// Set implements flag.Value{}.
@@ -204,7 +205,7 @@ func (sz Size) String() string {
}
// parseUnit will parse the byte size unit from string 's'.
-func parseUnit(s string) (Size, int, error) {
+func parseUnit(s string) (float64, int, error) {
// Check for string
if len(s) < 1 {
return 0, 0, ErrInvalidFormat