MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / humanReadableSize

Function humanReadableSize

controller/ai-local/iml.go:115–132  ·  view source on GitHub ↗

自动选择合适的单位

(size int64)

Source from the content-addressed store, hash-verified

113
114// 自动选择合适的单位
115func humanReadableSize(size int64) string {
116 const (
117 KB = 1000
118 MB = 1000 * KB
119 GB = 1000 * MB
120 )
121
122 switch {
123 case size >= GB:
124 return fmt.Sprintf("%.1f GB", math.Round(float64(size)/float64(GB)*10)/10)
125 case size >= MB:
126 return fmt.Sprintf("%.1f MB", math.Round(float64(size)/float64(MB)*10)/10)
127 case size >= KB:
128 return fmt.Sprintf("%.1f KB", math.Round(float64(size)/float64(KB)*10)/10)
129 default:
130 return fmt.Sprintf("%d B", size)
131 }
132}
133func (i *imlLocalModelController) Deploy(ctx *gin.Context) {
134
135 var input ai_local_dto.DeployInput

Callers 1

DeployMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected