Refactor Disk and Memory Size Formatting with Centralized Utility Function
- Extracted common size formatting logic to a new utility function `HumanSize` in utils package - Removed duplicate size formatting code from Disk and Memory configurations - Updated Disk and Memory modules to use the centralized size formatting utility - Uncommented and implemented disk usage calculation in Disk configuration - Improved code readability and maintainability by centralizing size conversion logic
This commit is contained in:
@@ -46,6 +46,9 @@ func downloadWithProgress(client *http.Client, url, dest string) (bool, string)
|
||||
size := resp.ContentLength
|
||||
var downloaded int64
|
||||
|
||||
// 打印下载信息
|
||||
fmt.Printf("开始下载文件: %s 文件大小: %s\n", url, HumanSizeInt(size))
|
||||
|
||||
// 创建带进度跟踪的Reader
|
||||
progressReader := &progressReader{
|
||||
Reader: resp.Body,
|
||||
|
||||
Reference in New Issue
Block a user