MCPcopy Index your code
hub / github.com/codechenx/FastTableViewer / makeProgressBar

Function makeProgressBar

utils.go:361–382  ·  view source on GitHub ↗

makeProgressBar creates a visual progress bar percent should be between 0 and 100 width is the number of characters for the bar

(percent float64, width int)

Source from the content-addressed store, hash-verified

359// percent should be between 0 and 100
360// width is the number of characters for the bar
361func makeProgressBar(percent float64, width int) string {
362 if percent < 0 {
363 percent = 0
364 }
365 if percent > 100 {
366 percent = 100
367 }
368
369 filled := int(float64(width) * percent / 100.0)
370 empty := width - filled
371
372 bar := "["
373 for i := 0; i < filled; i++ {
374 bar += "█"
375 }
376 for i := 0; i < empty; i++ {
377 bar += "░"
378 }
379 bar += fmt.Sprintf("] %.1f%%", percent)
380
381 return bar
382}

Callers 2

displayMethod · 0.85
startAsyncUpdateHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected