File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "github.com/schollz/progressbar/v3"
5+ "time"
6+ )
7+
8+ // This example illustrates a simple spinner that displays the number of
9+ // received calls
10+ func main () {
11+ bar := progressbar .NewOptions64 (
12+ - 1 ,
13+ progressbar .OptionSetDescription ("[Counter Example] Received" ),
14+ progressbar .OptionSetWidth (10 ),
15+ progressbar .OptionThrottle (65 * time .Millisecond ),
16+ progressbar .OptionShowCount (),
17+ progressbar .OptionSpinnerType (14 ),
18+ progressbar .OptionFullWidth (),
19+ progressbar .OptionSetRenderBlankState (true ),
20+ )
21+
22+ c := make (chan int )
23+
24+ go func (notify chan <- int ) {
25+ defer close (notify )
26+ for i := 0 ; i < 100 ; i ++ {
27+ c <- i
28+ time .Sleep (time .Millisecond * 100 )
29+ }
30+ }(c )
31+
32+ for v := range c {
33+ bar .Add (v )
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments