github.com/jfrog/jfrog-cli-core/v2@v2.51.0/utils/progressbar/generalprogressbar.go (about) 1 package progressbar 2 3 import ( 4 "github.com/vbauerster/mpb/v7" 5 "sync/atomic" 6 ) 7 8 type generalProgressBar struct { 9 bar *mpb.Bar 10 total int64 11 } 12 13 // IncGeneralProgressTotalBy increments the amount of total by n. 14 func (p *generalProgressBar) IncGeneralProgressTotalBy(n int64) { 15 atomic.AddInt64(&p.total, n) 16 if p.bar != nil { 17 p.bar.SetTotal(p.total, false) 18 } 19 } 20 21 // SetGeneralProgressTotal sets the amount of total to n. 22 func (p *generalProgressBar) SetGeneralProgressTotal(n int64) { 23 atomic.StoreInt64(&p.total, n) 24 if p.bar != nil { 25 p.bar.SetTotal(p.total, false) 26 } 27 } 28 29 func (p *generalProgressBar) GetBar() *mpb.Bar { 30 return p.bar 31 } 32 33 func (p *generalProgressBar) GetTotal() int64 { 34 return p.total 35 }