spinner is a simple package to add a spinner / progress indicator to any terminal application. Examples can be found below as well as full examples in the examples directory.
For more detail about the library and its features, reference your local godoc once installed.
Contributions welcome!
go get github.com/briandowns/spinner
(Numbered by their slice index)
-
←↖↑↗→↘↓↙
-
▁▃▄▅▆▇█▇▆▅▄▃▁
-
▖▘▝▗
-
┤┘┴└├┌┬┐
-
◢◣◤◥
-
◰◳◲◱
-
◴◷◶◵
-
◐◓◑◒
-
.oO@*
-
|/-\
-
◡◡⊙⊙◠◠
-
⣾⣽⣻⢿⡿⣟⣯⣷
-
>))'> >))'> >))'> >))'> >))'> <'((< <'((< <'((<
-
⠁⠂⠄⡀⢀⠠⠐⠈
-
⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏
-
abcdefghijklmnopqrstuvwxyz
-
▉▊▋▌▍▎▏▎▍▌▋▊▉
-
■□▪▫
-
←↑→↓
-
╫╪
-
⇐⇖⇑⇗⇒⇘⇓⇙
-
⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈
-
⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈
-
⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁
-
⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋
-
ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン
-
. .. ...
-
▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▏▎▍▌▋▊▉█▇▆▅▄▃▂▁
-
.oO°Oo.
-
+x
-
v<^>
-
>>---> >>---> >>---> >>---> >>---> <---<< <---<< <---<< <---<< <---<<
-
| || ||| |||| ||||| |||||| ||||| |||| ||| || |
-
[] [=] [==] [===] [====] [=====] [======] [=======] [========] [=========] [==========]
-
(*---------) (-*--------) (--*-------) (---*------) (----*-----) (-----*----) (------*---) (-------*--) (--------*-) (---------*)
-
█▒▒▒▒▒▒▒▒▒ ███▒▒▒▒▒▒▒ █████▒▒▒▒▒ ███████▒▒▒ ██████████
- Start
- Stop
- Restart
- Reverse direction
- Update the spinner character set
- Update the spinner speed
- Prefix or append text
- Change spinner color
- Get spinner status
package main
import (
"github.com/briandowns/spinner"
"time"
)
func main() {
s := spinner.New(spinner.CharSets[9], 100*time.Millisecond) // Build our new spinner
s.Start() // Start the spinner
time.Sleep(4 * time.Second) // Run for some time to simulate work
s.Stop()
}
s.UpdateCharSet(spinner.CharSets[1]) // Update spinner to use a different character set
s.Restart() // Restart the spinner
time.Sleep(4 * time.Second)
s.Stop()
s.UpdateSpeed(200 * time.Millisecond) // Update the speed the spinner spins at
s.Restart()
time.Sleep(4 * time.Second)
s.Stop()
s.Reverse() // Reverse the direction the spinner is spinning
s.Restart()
time.Sleep(4 * time.Second)
s.Stop()
(or send me an issue or pull request to add to the project)
someSet := []string{"+", "-"}
s := spinner.New(someSet, 100*time.Millisecond)
s.Prefix = "prefixed text: " // Prefix text before the spinner
s.Suffix = " :appended text" // Append text after the spinner
Set or change the color of the spinner. Default color is white. This will restart the spinner with the new color.
s.Color("red") // Set the spinner color to red
setOfDigits := spinner.GenerateNumberSequence(25) // Generate a 25 digit string of numbers
s := spinner.New(setOfDigits, 100*time.Millisecond)
fmt.Println(s.ST)