progressbar

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2018 License: MIT Imports: 7 Imported by: 296 modules, 291 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

progressbar

travis go report card coverage godocs

A very simple thread-safe progress bar which should work on every OS without problems. I needed a progressbar for croc and everything I tried had problems, so I made another one.

Example of progress bar

Install

go get -u github.com/schollz/progressbar

Usage

Basic usage:

bar := progressbar.New(100)
for i := 0; i < 100; i++ {
    bar.Add(1)
    time.Sleep(10 * time.Millisecond)
}

which looks like:

 100% |████████████████████████████████████████| [1s:0s]            

The times at the end show the elapsed time and the remaining time, respectively.

Contributing

Pull requests are welcome. Feel free to...

  • Revise documentation
  • Add new features
  • Fix bugs
  • Suggest improvements

License

MIT

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProgressBar

type ProgressBar struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ProgressBar is a thread-safe, simple progress bar

Example
bar := New(10)
bar.SetMax(100)
bar.SetSize(10)
bar.Reset()
time.Sleep(1 * time.Second)
bar.Add(10)
Output:
10% |█         | [1s:9s]

func New

func New(max int) *ProgressBar

New returns a new ProgressBar with the specified maximum

func (*ProgressBar) Add

func (p *ProgressBar) Add(num int) error

Add with increase the current count on the progress bar

func (*ProgressBar) Reset

func (p *ProgressBar) Reset()

Reset will reset the clock that is used to calculate current time and the time left.

func (*ProgressBar) SetMax

func (p *ProgressBar) SetMax(num int)

SetMax sets the total number of the progress bar

func (*ProgressBar) SetSize

func (p *ProgressBar) SetSize(size int)

SetSize sets the size of the progress bar.

func (*ProgressBar) SetTheme added in v0.5.0

func (p *ProgressBar) SetTheme(theme []string)

func (*ProgressBar) SetWriter added in v0.5.0

func (p *ProgressBar) SetWriter(w io.Writer)

SetWriter will specify a different writer than os.Stdout

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL