summaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster/mpb/internal/percentage.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/internal/percentage.go')
-rw-r--r--vendor/github.com/vbauerster/mpb/internal/percentage.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/vendor/github.com/vbauerster/mpb/internal/percentage.go b/vendor/github.com/vbauerster/mpb/internal/percentage.go
new file mode 100644
index 000000000..3c8defb7d
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/internal/percentage.go
@@ -0,0 +1,10 @@
+package internal
+
+// Percentage is a helper function, to calculate percentage.
+func Percentage(total, current, width int64) int64 {
+ if total <= 0 {
+ return 0
+ }
+ p := float64(width*current) / float64(total)
+ return int64(Round(p))
+}