don't let set negative current
Vladimir Bauer
3 years ago
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // SetCurrent sets progress' current to an arbitrary value. |
| 222 | // Setting a negative value will cause a panic. | |
| 223 | 222 | func (b *Bar) SetCurrent(current int64) { |
| 223 | if current < 0 { | |
| 224 | return | |
| 225 | } | |
| 224 | 226 | select { |
| 225 | 227 | case b.operateState <- func(s *bState) { |
| 226 | 228 | s.current = current |