func drawTextFormatPercent(prefix string, progress, total int64) string {
	return fmt.Sprintf("%s: %d%%", prefix, uint(float32(progress)/float32(total)*100))
}
drawTextFormatPercent is a drawTextFormatFunc that formats the progress
into a percentage
package main
import (
	"fmt"
	"io"
	"strings"
)
type drawFunc func(string, int64, int64) error
type drawTextFormatFunc func(string, int64, int64) string
func drawTerminalf(w io.Writer, f drawTextFormatFunc) drawFunc {
	var maxLength int
	return func(prefix string, progress, total int64) error {
		if progress == -1 && total == -1 {
			_, err := fmt.Fprintf(w, strings.Repeat(" ", maxLength))
			return err
		}
		line := f(prefix, progress, total)
		if len(line) < maxLength {
			line = fmt.Sprintf(
				"%s%s",
				line,
				strings.Repeat(" ", maxLength-len(line)))
		}
		maxLength = len(line)
		_, err := fmt.Fprint(w, line+"\r")
		return err
	}
}