test: add print map misc func

This commit is contained in:
Auztin Zhai
2024-05-19 10:45:53 -04:00
parent be3f1aac8a
commit d6ba1d9f8e

22
test/misc/misc.go Normal file
View File

@@ -0,0 +1,22 @@
package misc
import (
"fmt"
"strconv"
"strings"
"time"
)
func PrintMap(m map[string]uint64) {
var maxLenKey int
for k := range m {
if len(k) > maxLenKey {
maxLenKey = len(k)
}
}
for k, v := range m {
fmt.Println(k + ": " + strings.Repeat(" ", maxLenKey-len(k)) + strconv.FormatUint(v, 10))
}
fmt.Println(" -----", time.Now().Format("2006-01-02 15:04:05"))
}