refactor(bodylimit): 将 FormatSize 改为私有函数 formatSize

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
xfy 2026-04-10 13:22:35 +08:00
parent 941c44b798
commit 5e86f47650
2 changed files with 4 additions and 4 deletions

View File

@ -279,7 +279,7 @@ func ParseSize(sizeStr string) (int64, error) {
//
// 返回值:
// - string: 格式化后的字符串,如 "1mb", "10kb" 等
func FormatSize(size int64) string {
func formatSize(size int64) string {
const (
KB = 1024
MB = 1024 * KB

View File

@ -62,10 +62,10 @@ func TestFormatSize(t *testing.T) {
}
for _, tt := range tests {
t.Run(FormatSize(tt.input), func(t *testing.T) {
got := FormatSize(tt.input)
t.Run(formatSize(tt.input), func(t *testing.T) {
got := formatSize(tt.input)
if got != tt.expected {
t.Errorf("FormatSize(%d) = %s, want %s", tt.input, got, tt.expected)
t.Errorf("formatSize(%d) = %s, want %s", tt.input, got, tt.expected)
}
})
}