Exemplo n.º 1
0
func (s *Spinner) Stop() {
	if log.GetLogLevel() == log.LogLevel["ERROR"] {
		return
	}
	s.lock.Lock()
	defer s.lock.Unlock()
	if s.active {
		s.active = false
		fmt.Print(" Done.\n")
		s.stopChan <- struct{}{}
	}
}
Exemplo n.º 2
0
func (s *Spinner) Start() {
	if s.active || log.GetLogLevel() == log.LogLevel["ERROR"] {
		return
	}
	s.active = true
	fmt.Print(s.prefix)
	go func() {
		for {
			select {
			case <-s.stopChan:
				return
			default:
				s.lock.Lock()
				fmt.Print(".")
				delay := s.Delay
				s.lock.Unlock()
				time.Sleep(delay)
			}
		}
	}()
}