func (b *Bar) Set(n int) error {
	b.mtx.Lock()
	defer b.mtx.Unlock()
	if n > b.Total {
		return ErrMaxCurrentReached
	}
	b.current = n
	return nil
}
Set the current count of the bar. It returns ErrMaxCurrentReached when trying n exceeds the total value. This is atomic operation and concurancy safe.
package uiprogress
import (
	"bytes"
	"errors"
	"fmt"
	"sync"
	"time"
	"github.com/gosuri/uiprogress/util/strutil"
)
var (
	Fill byte = '='
	Head byte = '>'
	Empty byte = '-'
	LeftEnd byte = '['
	RightEnd byte = ']'
	Width = 70
	ErrMaxCurrentReached = errors.New("errors: current value is greater total value")
)
type Bar struct {
	Total int
	LeftEnd byte
	RightEnd byte
	Fill byte
	Head byte
	Empty byte
	TimeStarted time.Time
	Width int
	timeElapsed time.Duration
	current     int
	mtx *sync.RWMutex
	appendFuncs  []DecoratorFunc
	prependFuncs []DecoratorFunc
}
type DecoratorFunc func(b *Bar) string
func NewBar(total int) *Bar {
	return &Bar{
		Total:    total,
		Width:    Width,
		LeftEnd:  LeftEnd,
		RightEnd: RightEnd,
		Head:     Head,
		Fill:     Fill,
		Empty:    Empty,
		mtx: &sync.RWMutex{},
	}
}