github.com/fzfile/BaiduPCS-Go@v0.0.0-20200606205115-4408961cf336/internal/pcsconfig/util.go (about) 1 package pcsconfig 2 3 import ( 4 "github.com/fzfile/BaiduPCS-Go/pcsutil/converter" 5 "strings" 6 ) 7 8 // AverageParallel 返回平均的下载最大并发量 9 func AverageParallel(parallel, downloadLoad int) int { 10 if downloadLoad < 1 { 11 return 1 12 } 13 14 p := parallel / downloadLoad 15 if p < 1 { 16 return 1 17 } 18 return p 19 } 20 21 func stripPerSecond(sizeStr string) string { 22 i := strings.LastIndex(sizeStr, "/") 23 if i < 0 { 24 return sizeStr 25 } 26 return sizeStr[:i] 27 } 28 29 func showMaxRate(size int64) string { 30 if size <= 0 { 31 return "不限制" 32 } 33 return converter.ConvertFileSize(size, 2) + "/s" 34 }