dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 07d3bfaafa0178a5373f00c6df974682671f178d
parent df1647d9aeaf462d1c3109cd58be7ac0accb76b8
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue, 31 Jan 2023 02:21:05 -0800

remove useless code

Diffstat:
Mcmd/dkfupload/main.go | 43+++++++++++++------------------------------
1 file changed, 13 insertions(+), 30 deletions(-)

diff --git a/cmd/dkfupload/main.go b/cmd/dkfupload/main.go @@ -291,35 +291,18 @@ func Ternary[T any](predicate bool, a, b T) T { return b } -func ShortDur(v interface{}) string { - if d, ok := v.(time.Duration); ok { - if d < time.Minute { - d = d.Round(time.Millisecond) - } else { - d = d.Round(time.Second) - } - s := d.String() - if strings.HasSuffix(s, "m0s") { - s = s[:len(s)-2] - } - if strings.HasSuffix(s, "h0m") { - s = s[:len(s)-2] - } - return s - } else if d, ok := v.(time.Time); ok { - return ShortDur(time.Until(d)) - } else if d, ok := v.(uint64); ok { - return ShortDur(time.Duration(d) * time.Second) - } else if d, ok := v.(int64); ok { - return ShortDur(time.Duration(d) * time.Second) - } else if d, ok := v.(int32); ok { - return ShortDur(time.Duration(d) * time.Second) - } else if d, ok := v.(int64); ok { - return ShortDur(time.Duration(d) * time.Second) - } else if d, ok := v.(float32); ok { - return ShortDur(time.Duration(d) * time.Second) - } else if d, ok := v.(float64); ok { - return ShortDur(time.Duration(d) * time.Second) +func ShortDur(d time.Duration) string { + if d < time.Minute { + d = d.Round(time.Millisecond) + } else { + d = d.Round(time.Second) + } + s := d.String() + if strings.HasSuffix(s, "m0s") { + s = s[:len(s)-2] + } + if strings.HasSuffix(s, "h0m") { + s = s[:len(s)-2] } - return "n/a" + return s }