• Stars
    star
    3,367
  • Rank 12,723 (Top 0.3 %)
  • Language
    Go
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A really basic thread-safe progress bar for Golang applications

progressbar

CI 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. In order to be OS agnostic I do not plan to support multi-line outputs.

Install

go get -u github.com/schollz/progressbar/v3

Usage

Basic usage

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

which looks like:

Example of basic bar

I/O operations

The progressbar implements an io.Writer so it can automatically detect the number of bytes written to a stream, so you can use it as a progressbar for an io.Reader.

req, _ := http.NewRequest("GET", "https://dl.google.com/go/go1.14.2.src.tar.gz", nil)
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()

f, _ := os.OpenFile("go1.14.2.src.tar.gz", os.O_CREATE|os.O_WRONLY, 0644)
defer f.Close()

bar := progressbar.DefaultBytes(
    resp.ContentLength,
    "downloading",
)
io.Copy(io.MultiWriter(f, bar), resp.Body)

which looks like:

Example of download bar

Progress bar with unknown length

A progressbar with unknown length is a spinner. Any bar with -1 length will automatically convert it to a spinner with a customizable spinner type. For example, the above code can be run and set the resp.ContentLength to -1.

which looks like:

Example of download bar with unknown length

Customization

There is a lot of customization that you can do - change the writer, the color, the width, description, theme, etc. See all the options.

bar := progressbar.NewOptions(1000,
    progressbar.OptionSetWriter(ansi.NewAnsiStdout()), //you should install "github.com/k0kubun/go-ansi"
    progressbar.OptionEnableColorCodes(true),
    progressbar.OptionShowBytes(true),
    progressbar.OptionSetWidth(15),
    progressbar.OptionSetDescription("[cyan][1/3][reset] Writing moshable file..."),
    progressbar.OptionSetTheme(progressbar.Theme{
        Saucer:        "[green]=[reset]",
        SaucerHead:    "[green]>[reset]",
        SaucerPadding: " ",
        BarStart:      "[",
        BarEnd:        "]",
    }))
for i := 0; i < 1000; i++ {
    bar.Add(1)
    time.Sleep(5 * time.Millisecond)
}

which looks like:

Example of customized bar

Contributing

Pull requests are welcome. Feel free to...

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

Thanks

Thanks @Dynom for massive improvements in version 2.0!

Thanks @CrushedPixel for adding descriptions and color code support!

Thanks @MrMe42 for adding some minor features!

Thanks @tehstun for some great PRs!

Thanks @Benzammour and @haseth for helping create v3!

Thanks @briandowns for compiling the list of spinners.

License

MIT

More Repositories

1

croc

Easily and securely send things from one computer to another 🐊 📦
Go
23,068
star
2

howmanypeoplearearound

Count the number of people around you 👨‍👨‍👦 by monitoring wifi signals 📡
Python
6,759
star
3

find

High-precision indoor positioning framework for most wifi-enabled devices.
Go
5,006
star
4

find3

High-precision indoor positioning framework, version 3.
Go
4,494
star
5

hostyoself

Host yo' self from your browser, your phone, your toaster.
Go
1,777
star
6

find-lf

Track the location of every Wi-Fi device (📱) in your house using Raspberry Pis and FIND
Go
977
star
7

rwtxt

A cms for absolute minimalists.
JavaScript
934
star
8

cowyo

A feature-rich wiki webserver for minimalists 🐮 💬
JavaScript
906
star
9

raspberry-pi-turnkey

How to make a Raspberry Pi image that can be deployed anywhere and assigned to a WiFi network without SSH 👌
Python
767
star
10

peerdiscovery

Pure-Go library for cross-platform local peer discovery using UDP multicast 👩 🔁 👩
Go
594
star
11

closestmatch

Golang library for fuzzy matching within a set of strings 📃
Go
407
star
12

gojot

A command-line journal that is distributed and encrypted, making it easy to jot notes 📓
Go
343
star
13

PIanoAI

Realtime piano learning and accompaniment from a Pi-powered AI 🎹
Go
331
star
14

spotifydownload

A dependency-free Spotify playlist downloader that should just work
Shell
318
star
15

poetry-generator

A Python2 based Backus-Naur poetry generator
Python
294
star
16

musicsaur

Music synchronization from your browser.
Go
280
star
17

offlinenotepad

An offline-first, secure, private notepad. 📔 ✏️
JavaScript
236
star
18

pluck

Pluck text in a fast and intuitive way 🐓
Go
214
star
19

pake

PAKE library for generating a strong secret between parties over an insecure channel
Go
180
star
20

miti

miti is a musical instrument textual interface. Basically, its MIDI, but with human-readable text. 🎵
Go
157
star
21

meanrecipe

Get a consensus recipe for your next meal. 🍪 🍰
Go
156
star
22

find3-cli-scanner

The command-line scanner that supports Bluetooth and WiFi
Go
142
star
23

playlistfromsong

Create an offline music playlist from a single song 🎶
Python
136
star
24

recursive-recipes

Visualize the recursive nature of recipes 🍰 🍪
Go
135
star
25

teoperator

Make OP-1 and OP-Z drum and synth patches from any sound. 🎹
Go
134
star
26

jsonstore

Simple thread-safe in-memory JSON key-store with persistent backend
Go
130
star
27

getsong

Download any song mp3 with no dependencies except ffmpeg
Go
124
star
28

find3-android-scanner

An android app that scans Bluetooth and WiFi for FIND3
Java
119
star
29

linkcrawler

Cross-platform persistent and distributed web crawler 🔗
Go
111
star
30

ingredients

Extract recipe ingredients from any recipe website on the internet.
HTML
109
star
31

share

Simple file sharing from the browser and the command-line.
Go
106
star
32

faas

Make any Go function into a API (FaaS)
Go
96
star
33

find-maraudersmap

Internal positioning for everyone, in the style of Harry Potter
HTML
67
star
34

broadcast-server

A simple Go server that broadcasts any data/stream.
Go
65
star
35

streammyaudio

Easily stream audio from any computer to the internet.
HTML
63
star
36

cowyodel

Easily move things between computers with a code phrase and https://cowyo.com 🐮 💬
Go
62
star
37

extract_recipe

Extract recipes from websites, calculates cooking times, collects nutrition info from USDA database
Python
61
star
38

crawdad

Cross-platform persistent and distributed web crawler 🦀
Go
61
star
39

duct

Inspired by patchbay.pub
Go
59
star
40

svg2gcode

Converts svg to gcode for pen plotters
Go
53
star
41

snaptext

A simple webapp to send and receive self-destructing messages in real-time. ✉️ ⚡
Go
53
star
42

pywebsitechanges

Change detection with a simple Python script to email you whenever a website changes.
Python
51
star
43

rpi_ai

An AI developed for the Raspberry Pi
Python
50
star
44

websitechanges

Alerts you via email about a website change.
Go
47
star
45

kiki

An experimental social network that works offline.
Go
46
star
46

pikocore

source for the pikocore drum machine
C++
46
star
47

goagrep

agrep-like fuzzy matching, but made faster using Golang and precomputation.
Go
45
star
48

oooooo

digital tape loops for monome norns, x6.
Lua
43
star
49

readable

Making web pages readable in a browser and in the command line 🔗 📖
Go
41
star
50

onetwothree

A responsive minimalist theme for Hugo that is simple as 1, 2, 3
CSS
39
star
51

logue

A collection of Korg logue patches for the NTS-1 (or possibly minilogue XD)
C
37
star
52

midi2cv-pi

Use a simple Python script, a few wires, and a MCP4725 to convert any MIDI signal to a control voltage.
Python
37
star
53

sqlite3dump

A Golang library for dumping SQL text
Go
35
star
54

wifiscan

A platform-independent WiFi scanning library for getting BSSID + RSSI
Go
35
star
55

norns.online

online norns with norns.online
Go
35
star
56

bol

Command-line and web journal that stays synchronized and encrypted across devices
Go
34
star
57

syncdir

Automatically discover peers and synchronize a folder
Go
33
star
58

18000

18,000 seconds of music.
SuperCollider
32
star
59

beowulf_ssh_cluster

Skeleton program for a simple Beowulf cluster that uses ssh to communicate
Python
31
star
60

markdown2tufte

Process markdown into a nice Tufte-like website 📖
CSS
31
star
61

carp

Browser-based Korg NTS-1 chord arpeggiator (carp) sequencer
JavaScript
28
star
62

httpfileserver

Wrapper for Golang http.FileServer that is faster (serving from memory) and uses less bandwidth (gzips when possible)
Go
27
star
63

nyblcore

ATtiny85-based sample machine with tempo-based effects.
C++
27
star
64

browsersync

A simple live-reloading tool for developing HTML.
Go
26
star
65

tape-synth

Instructions to create a cassette synthesizer.
Go
26
star
66

squirrel

Like curl, or wget, but downloads directly go to a SQLite databse
Go
25
star
67

workshops

workshops
SuperCollider
23
star
68

patchitup

Backup your file to your remote server using minimum bandwidth.
Go
23
star
69

logger

Simplistic, opinionated logging for Golang
Go
21
star
70

mnemonicode

Go
20
star
71

boltdb-server

Fancy server and Go package for connecting to BoltDB databases
Go
20
star
72

zget

zack's wget
Go
19
star
73

wormhole

Transfer files over TCP in Go
Go
19
star
74

quotation-explorer

Explore and search over 120,000 quotations, with the click of a mouse 🌎💬
Go
19
star
75

_core

_core firmware for rp2040-based sample mangling devices
C
19
star
76

o-o-o

dot-connected fm synth and sequencer for norns
Lua
18
star
77

norns-desktop

norns in docker
Dockerfile
17
star
78

tapedeck

norns tape deck emulator.
Lua
17
star
79

amenbreak

a dedicated amen break script for norns.
Lua
16
star
80

prevent-link-rot

Simple utility to convert links in any file to permanent links via the https://archive.org/web/ or http://perma.cc
HTML
16
star
81

anonfiction

A CMS for reading and writing stories in a online magazine format. 📖
Go
16
star
82

raw

Go
16
star
83

mx.samples

like mr. radar or mr.coffee but for samples on norns.
Lua
15
star
84

supertonic

an instrospective drum machien
Lua
15
star
85

mx.synths

norns script for polyphonic synths
Lua
14
star
86

autojack

norns mod for automatically jacking in usb audio
Lua
14
star
87

fbdb

File based database
Go
14
star
88

broadcast

Lua
14
star
89

zxcvbn

a norns script for a tracker on norns.
Lua
14
star
90

heartbpm

Control the tempo of electronic instruments with your heart rate. 💗 🎵
JavaScript
14
star
91

web-archiver

A tiny Python clone of https://archive.org/web/ for your own personal websites.
Python
13
star
92

paracosms

norns script to play and sample many samples.
Lua
13
star
93

album-at-the-place

Open-sourcing my latest music album.
12
star
94

indeterminate-music

A framework for creating indeterminate music (in development) 🎵
HTML
12
star
95

ipfs-connect

Easily connect two computers in the IPFS
Go
11
star
96

googleit

Get results from search engines.
Go
11
star
97

stringsizer

A very simple way to encode short strings.
Go
11
star
98

supercollisions

collection of SuperCollider scripts
SuperCollider
11
star
99

amen

sampler & mangler for monome norns
Lua
11
star
100

string_matching

A simple and fast approach to selecting the best string in a list of strings despite errors or mispelling.
Python
11
star