@@ -123,7 +123,8 @@ func Stat(cmd *cobra.Command, _ []string) error {
123
123
totalSize += f .size
124
124
}
125
125
126
- header := fmt .Sprintf ("Total: %s\t %s" , getReduce (unit , totalSize ), color .HiGreenString (dir ))
126
+ val , reduceUnit := getReduce (unit , totalSize )
127
+ header := fmt .Sprintf ("Total: %0.3f%s\t %s" , val , reduceUnit , color .HiGreenString (dir ))
127
128
colorPrintln (header )
128
129
colorPrintln (strings .Repeat ("-" , len (header )+ 2 ))
129
130
printFiles (files , 0 , depth , unit )
@@ -234,8 +235,8 @@ func printFiles(files []file, n, depth int, unit string) {
234
235
235
236
bar := strings .Repeat (" " , n ) + "|--"
236
237
for _ , f := range files {
237
-
238
- part1 := fmt .Sprintf ("%s %s %s" , f .modifyTime .Format ("20060102 15:04:05" ), f .mode , getReduce ( unit , f . size ) )
238
+ val , reduceUnit := getReduce ( unit , f . size )
239
+ part1 := fmt .Sprintf ("%s %s %9.3f% s" , f .modifyTime .Format ("20060102 15:04:05" ), f .mode , val , reduceUnit )
239
240
part2 := color .HiGreenString (f .name )
240
241
var s = bar
241
242
if f .isDir {
@@ -251,7 +252,7 @@ func printFiles(files []file, n, depth int, unit string) {
251
252
}
252
253
}
253
254
254
- func getReduce (unit string , n int64 ) string {
255
+ func getReduce (unit string , n int64 ) ( float64 , string ) {
255
256
reduce := 0
256
257
switch unit {
257
258
case "B" :
@@ -278,7 +279,7 @@ func getReduce(unit string, n int64) string {
278
279
279
280
}
280
281
281
- return fmt . Sprintf ( "%9.3f%s" , float64 (n )/ float64 (units [reduce ]), unitStrings [reduce ])
282
+ return float64 (n ) / float64 (units [reduce ]), unitStrings [reduce ]
282
283
}
283
284
284
285
func colorPrintln (a ... any ) {
0 commit comments