diff --git a/_examples/panic/go.mod b/_examples/panic/go.mod deleted file mode 100644 index e44c113..0000000 --- a/_examples/panic/go.mod +++ /dev/null @@ -1,13 +0,0 @@ -module github.com/vbauerster/mpb/_examples/panic - -go 1.17 - -require github.com/vbauerster/mpb/v8 v8.0.2 - -require ( - github.com/VividCortex/ewma v1.2.0 // indirect - github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect - github.com/mattn/go-runewidth v0.0.13 // indirect - github.com/rivo/uniseg v0.2.0 // indirect - golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect -) diff --git a/_examples/panic/main.go b/_examples/panic/main.go deleted file mode 100644 index 00e8be6..0000000 --- a/_examples/panic/main.go +++ /dev/null @@ -1,49 +0,0 @@ -package main - -import ( - "fmt" - "os" - "strings" - "sync" - "time" - - "github.com/vbauerster/mpb/v8" - "github.com/vbauerster/mpb/v8/decor" -) - -func main() { - var wg sync.WaitGroup - // passed wg will be accounted at p.Wait() call - p := mpb.New( - mpb.WithWaitGroup(&wg), - mpb.WithDebugOutput(os.Stderr), - ) - - wantPanic := strings.Repeat("Panic ", 64) - numBars := 3 - wg.Add(numBars) - - for i := 0; i < numBars; i++ { - name := fmt.Sprintf("b#%02d:", i) - bar := p.AddBar(100, mpb.BarID(i), mpb.PrependDecorators(panicDecorator(name, wantPanic))) - - go func() { - defer wg.Done() - for i := 0; i < 100; i++ { - time.Sleep(50 * time.Millisecond) - bar.Increment() - } - }() - } - // wait for passed wg and for all bars to complete and flush - p.Wait() -} - -func panicDecorator(name, panicMsg string) decor.Decorator { - return decor.Any(func(st decor.Statistics) string { - if st.ID == 1 && st.Current >= 42 { - panic(panicMsg) - } - return name - }) -}