Documentation
¶
Overview ¶
Package progress provides methods and structs for creating terminal progress bar
Index ¶
- Constants
- Variables
- type Bar
- func (b *Bar) Add(v int)
- func (b *Bar) Add64(v int64)
- func (b *Bar) Current() int64
- func (b *Bar) Finish()
- func (b *Bar) IsFinished() bool
- func (b *Bar) IsStarted() bool
- func (b *Bar) Name() string
- func (b *Bar) Reader(r io.Reader) io.Reader
- func (b *Bar) SetCurrent(v int64)
- func (b *Bar) SetName(name string)
- func (b *Bar) SetTotal(v int64)
- func (b *Bar) Start()
- func (b *Bar) Total() int64
- func (b *Bar) UpdateSettings(s Settings)
- func (b *Bar) Writer(w io.Writer) io.Writer
- type PassThruCalc
- type Settings
Examples ¶
Constants ¶
const MIN_WIDTH = 80
MIN_WIDTH is minimal progress bar width
const PROGRESS_BAR_SYMBOL = "—"
PROGRESS_BAR_SYMBOL is symbol for creating progress bar
Variables ¶
var DefaultSettings = Settings{ RefreshRate: 100 * time.Millisecond, NameColorTag: "{b}", BarFgColorTag: "{r}", BarBgColorTag: "{s-}", PercentColorTag: "{m}", SpeedColorTag: "{r}", ProgressColorTag: "{g}", RemainingColorTag: "{c}", ShowName: true, ShowPercentage: true, ShowProgress: true, ShowSpeed: true, ShowRemaining: true, IsSize: true, Width: 88, }
DefaultSettings is default progress bar settings
Functions ¶
This section is empty.
Types ¶
type Bar ¶
type Bar struct {
// contains filtered or unexported fields
}
Bar is progress bar struct
func New ¶
New creates new progress bar struct
Example ¶
pb := New(1000, "Downloading...")
pbs := DefaultSettings
pbs.RefreshRate = 50 * time.Millisecond
pbs.ShowSpeed = false
pbs.ShowRemaining = false
defer pb.Finish()
pb.Start()
for range time.NewTicker(time.Second).C {
pb.Add(1)
}
func (*Bar) IsFinished ¶
IsFinished returns true if progress proccesing is finished
func (*Bar) SetCurrent ¶
SetCurrent sets current progress bar value
func (*Bar) UpdateSettings ¶
UpdateSettings updates progress settings
type PassThruCalc ¶
type PassThruCalc struct {
// contains filtered or unexported fields
}
PassThruCalc is pass thru calculator struct
func NewPassThruCalc ¶
func NewPassThruCalc(total int64, winSizeSec float64) *PassThruCalc
NewPassThruCalc creates new pass thru calculator
func (*PassThruCalc) Calculate ¶
func (p *PassThruCalc) Calculate(v int64) (float64, time.Duration)
Calculate calculates number of objects per seconds and remaining time
func (*PassThruCalc) SetTotal ¶
func (p *PassThruCalc) SetTotal(v int64)
SetTotal sets total number of objects
type Settings ¶
type Settings struct {
RefreshRate time.Duration
NameColorTag string
BarFgColorTag string
BarBgColorTag string
PercentColorTag string
ProgressColorTag string
SpeedColorTag string
RemainingColorTag string
ShowSpeed bool
ShowName bool
ShowPercentage bool
ShowProgress bool
ShowRemaining bool
Width int
NameSize int
IsSize bool
}
Settings contains progress bar settings