Documentation ¶
Index ¶
- Constants
- Variables
- func Format(i int64, units int) string
- func FormatBytes(i int64) (result string)
- type Callback
- type ProgressBar
- func (pb *ProgressBar) Add(add int) int
- func (pb *ProgressBar) Add64(add int64) int64
- func (pb *ProgressBar) Finish()
- func (pb *ProgressBar) FinishPrint(str string)
- func (pb *ProgressBar) Format(format string) (bar *ProgressBar)
- func (pb *ProgressBar) Increment() int
- func (pb *ProgressBar) NewProxyReader(r io.Reader) *Reader
- func (pb *ProgressBar) Postfix(postfix string) (bar *ProgressBar)
- func (pb *ProgressBar) Prefix(prefix string) (bar *ProgressBar)
- func (pb *ProgressBar) Read(p []byte) (n int, err error)
- func (pb *ProgressBar) Set(current int)
- func (pb *ProgressBar) SetMaxWidth(width int) (bar *ProgressBar)
- func (pb *ProgressBar) SetRefreshRate(rate time.Duration) (bar *ProgressBar)
- func (pb *ProgressBar) SetUnits(units int) (bar *ProgressBar)
- func (pb *ProgressBar) SetWidth(width int) (bar *ProgressBar)
- func (pb *ProgressBar) Start()
- func (pb *ProgressBar) Update()
- func (pb *ProgressBar) Write(p []byte) (n int, err error)
- type Reader
Constants ¶
View Source
const ( // By default, without type handle U_NO = 0 // Handle as b, Kb, Mb, etc U_BYTES = 1 )
View Source
const ( // Default refresh rate - 200ms DEFAULT_REFRESH_RATE = time.Millisecond * 200 FORMAT = "[=>-]" )
View Source
const ( TIOCGWINSZ = 0x5413 TIOCGWINSZ_OSX = 1074295912 )
Variables ¶
View Source
var ( DefaultRefreshRate = DEFAULT_REFRESH_RATE BarStart, BarEnd, Empty, Current, CurrentN string )
DEPRECATED variables for backward compatibility, from now do not work use pb.Format and pb.SetRefreshRate
Functions ¶
func FormatBytes ¶
Convert bytes to human readable string. Like a 2 MB, 64.2 KB, 52 B
Types ¶
type Callback ¶
type Callback func(out string)
Callback for custom output For example:
bar.Callback = func(s string) { mySuperPrint(s) }
type ProgressBar ¶
type ProgressBar struct { Total int64 RefreshRate time.Duration ShowPercent, ShowCounters bool ShowSpeed, ShowTimeLeft, ShowBar bool ShowFinalTime bool Output io.Writer Callback Callback NotPrint bool Units int Width int ForceWidth bool ManualUpdate bool BarStart string BarEnd string Empty string Current string CurrentN string // contains filtered or unexported fields }
func New64 ¶
func New64(total int64) (pb *ProgressBar)
Create new progress bar object uding int64 as total
func (*ProgressBar) Add64 ¶
func (pb *ProgressBar) Add64(add int64) int64
func (*ProgressBar) FinishPrint ¶
func (pb *ProgressBar) FinishPrint(str string)
End print and write string 'str'
func (*ProgressBar) Format ¶
func (pb *ProgressBar) Format(format string) (bar *ProgressBar)
Set custom format for bar Example: bar.Format("[=>_]")
func (*ProgressBar) NewProxyReader ¶
func (pb *ProgressBar) NewProxyReader(r io.Reader) *Reader
Create new proxy reader over bar
func (*ProgressBar) Postfix ¶
func (pb *ProgressBar) Postfix(postfix string) (bar *ProgressBar)
Set postfix string
func (*ProgressBar) Prefix ¶
func (pb *ProgressBar) Prefix(prefix string) (bar *ProgressBar)
Set prefix string
func (*ProgressBar) Read ¶
func (pb *ProgressBar) Read(p []byte) (n int, err error)
implement io.Reader
func (*ProgressBar) SetMaxWidth ¶
func (pb *ProgressBar) SetMaxWidth(width int) (bar *ProgressBar)
Set max width, if width is bigger than terminal width, will be ignored
func (*ProgressBar) SetRefreshRate ¶
func (pb *ProgressBar) SetRefreshRate(rate time.Duration) (bar *ProgressBar)
Set bar refresh rate
func (*ProgressBar) SetUnits ¶
func (pb *ProgressBar) SetUnits(units int) (bar *ProgressBar)
Set units bar.SetUnits(U_NO) - by default bar.SetUnits(U_BYTES) - for Mb, Kb, etc
func (*ProgressBar) SetWidth ¶
func (pb *ProgressBar) SetWidth(width int) (bar *ProgressBar)
Set bar width
func (*ProgressBar) Update ¶
func (pb *ProgressBar) Update()
Write the current state of the progressbar
Click to show internal directories.
Click to hide internal directories.