We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7805e20 commit e77f5d5Copy full SHA for e77f5d5
common/format.go
@@ -17,8 +17,8 @@
17
package common
18
19
import (
20
- "fmt"
21
"regexp"
+ "strconv"
22
"strings"
23
"time"
24
)
@@ -66,17 +66,21 @@ func (t PrettyAge) String() string {
66
return "0"
67
}
68
// Accumulate a precision of 3 components before returning
69
- result, prec := "", 0
+ var (
70
+ builder strings.Builder
71
+ prec int
72
+ )
73
74
for _, unit := range ageUnits {
75
if diff >= unit.Size {
- result = fmt.Sprintf("%s%d%s", result, diff/unit.Size, unit.Symbol)
76
+ builder.WriteString(strconv.FormatInt(int64(diff/unit.Size), 10))
77
+ builder.WriteString(unit.Symbol)
78
diff %= unit.Size
79
80
if prec += 1; prec >= 3 {
81
break
82
83
84
- return result
85
+ return builder.String()
86
0 commit comments