Documentation ¶
Index ¶
- Constants
- func CalcPercentage(total, current int64, width, fill int) (int, int)
- func CountersString(s *Statistics, pairFormat string, unit Units) string
- func ETAString(s *Statistics) string
- func ElapsedString(s *Statistics) string
- func Format(i int64) *formatter
- func FormatF(i float64) *formatterF
- func NsecString(s *Statistics, nsecformat string, unit Units) string
- func PercentageString(s *Statistics) string
- type DecoratorFunc
- func Counters(pairFormat string, unit Units, minWidth int, conf byte) DecoratorFunc
- func DefDataPreBar(unit Units) DecoratorFunc
- func DynamicName(nameFn func(*Statistics) string, minWidth int, conf byte) DecoratorFunc
- func ETA(minWidth int, conf byte) DecoratorFunc
- func Elapsed(minWidth int, conf byte) DecoratorFunc
- func Name(name string, minWidth int, conf byte) DecoratorFunc
- func Nsec(nsecformat string, unit Units, minWidth int, conf byte) DecoratorFunc
- func Percentage(minWidth int, conf byte) DecoratorFunc
- func StaticName(name string, minWidth int, conf byte) DecoratorFunc
- type Statistics
- type Units
Constants ¶
const ( // DidentRight specifies identation direction. // |foo |b | With DidentRight // | foo| b| Without DidentRight DidentRight = 1 << iota // DwidthSync will auto sync max width. // Makes sense when there're more than one bar DwidthSync // DextraSpace adds extra space, makes sense with DwidthSync only. // When DidentRight bit set, the space will be added to the right, // otherwise to the left. DextraSpace // DSyncSpace is shortcut for DwidthSync|DextraSpace DSyncSpace = DwidthSync | DextraSpace )
const ( KiB = 1 << (iota * 10) MiB GiB TiB )
const ( KB = 1000 MB = KB * 1000 GB = MB * 1000 TB = GB * 1000 )
const ( // Unit_KiB Kibibyte = 1024 b Unit_KiB // Unit_kB Kilobyte = 1000 b Unit_kB // Unit_k Kibibyte = 1000 Unit_k )
const Unit_KB = Unit_kB
Unit_KB Kilobyte = 1000 b
const Unit_Kb = Unit_kB
Unit_Kb Kilobyte = 1000 b
Variables ¶
This section is empty.
Functions ¶
func CountersString ¶
func CountersString(s *Statistics, pairFormat string, unit Units) string
Counters provides basic counters decorator. Accepts pairFormat string, something like "%s / %s" to be used in fmt.Sprintf(pairFormat, current, total) and one of (Unit_KiB/Unit_kB) constant. If there're more than one bar, and you'd like to synchronize column width, conf param should have DwidthSync bit set.
func ETAString ¶
func ETAString(s *Statistics) string
ETA provides exponential-weighted-moving-average ETA decorator, shows the elapsed time after the progress has finished. If there're more than one bar, and you'd like to synchronize column width, conf param should have DwidthSync bit set.
func ElapsedString ¶
func ElapsedString(s *Statistics) string
Elapsed provides elapsed time decorator. If there're more than one bar, and you'd like to synchronize column width, conf param should have DwidthSync bit set.
func NsecString ¶
func NsecString(s *Statistics, nsecformat string, unit Units) string
Nsec provides basic Num/sec decorator. Accepts string, something like "%s/s" to be used in fmt.Sprintf(nsecformat, current) and one of (Unit_KiB/Unit_kB) constant. If there're more than one bar, and you'd like to synchronize column width, conf param should have DwidthSync bit set.
func PercentageString ¶
func PercentageString(s *Statistics) string
Percentage provides percentage decorator. If there're more than one bar, and you'd like to synchronize column width, conf param should have DwidthSync bit set.
Types ¶
type DecoratorFunc ¶
type DecoratorFunc func(s *Statistics, myWidth chan<- int, maxWidth <-chan int) string
DecoratorFunc is a function that can be prepended and appended to the progress bar
func DefDataPreBar ¶
func DefDataPreBar(unit Units) DecoratorFunc
func DynamicName ¶
func DynamicName(nameFn func(*Statistics) string, minWidth int, conf byte) DecoratorFunc
DynamicName to be used, when there is a plan to change the name once or several times during progress rendering process. If there're more than one bar, and you'd like to synchronize column width, conf param should have DwidthSync bit set.
func ETA ¶
func ETA(minWidth int, conf byte) DecoratorFunc
func Elapsed ¶
func Elapsed(minWidth int, conf byte) DecoratorFunc
func Name ¶
func Name(name string, minWidth int, conf byte) DecoratorFunc
Name deprecated, use StaticName instead
func Percentage ¶
func Percentage(minWidth int, conf byte) DecoratorFunc
func StaticName ¶
func StaticName(name string, minWidth int, conf byte) DecoratorFunc
StaticName to be used, when there is no plan to change the name during whole life of a progress rendering process
type Statistics ¶
type Statistics struct { ID int Completed bool Aborted bool Total int64 Current int64 StartTime time.Time TimeElapsed time.Duration TimePerItemEstimate time.Duration }
Statistics represents statistics of the progress bar. Cantains: Total, Current, TimeElapsed, TimePerItemEstimate
func (*Statistics) Eta ¶
func (s *Statistics) Eta() time.Duration
Eta returns exponential-weighted-moving-average ETA estimator