Tui 模块开发完成,数据正常写入数据库

This commit is contained in:
2026-03-06 16:33:08 +08:00
parent 3f5e333a4d
commit 8bc4f4fe04
7 changed files with 674 additions and 535 deletions

View File

@@ -3,6 +3,7 @@ package utils
import (
"crypto/rand"
"encoding/hex"
"fmt"
"os"
"os/exec"
"time"
@@ -32,6 +33,29 @@ func GetTimestamp() string {
return time.Now().Format("2006-01-02 15:04:05")
}
func OutputMaps(maps map[string]string) []string {
output := []string{}
maxLen := 0
for key := range maps {
if len(key) > maxLen {
maxLen = len(key)
}
}
// 使用动态宽度的格式化字符串输出
// %-*s 的含义
// %: 格式化开始
// -: 左对齐,默认是右对齐
// *: 表示宽度由后续参数指定(maxLen)
// s: 表示字符串类型
for key, value := range maps {
output = append(output, fmt.Sprintf("%-*s: %s", maxLen, key, value))
}
return output
}
// 定义短语
const (
NoAvailableNetworkInterfaces = "No available network interfaces"