spinner.go
func (s *Spinner) Start() {
	s.lock.Lock()
	if s.active {
		s.lock.Unlock()
		return
	}
	if s.HideCursor && runtime.GOOS != "windows" {
		// hides the cursor
		fmt.Print("\033[?25l")
	}
	s.active = true
	s.lock.Unlock()

	go func() {
		for {
			for i := 0; i < len(s.chars); i++ {
				select {
				case <-s.stopChan:
					return
				default:
					s.lock.Lock()
					s.erase()
					var outColor string
					if runtime.GOOS == "windows" {
						if s.Writer == os.Stderr {
							outColor = fmt.Sprintf("\r%s%s%s ", s.Prefix, s.chars[i], s.Suffix)
						} else {
							outColor = fmt.Sprintf("\r%s%s%s ", s.Prefix, s.color(s.chars[i]), s.Suffix)
						}
					} else {
						outColor = fmt.Sprintf("%s%s%s ", s.Prefix, s.color(s.chars[i]), s.Suffix)
					}
					outPlain := fmt.Sprintf("%s%s%s ", s.Prefix, s.chars[i], s.Suffix)
					fmt.Fprint(s.Writer, outColor)
					s.lastOutput = outPlain
					delay := s.Delay
					s.lock.Unlock()

					time.Sleep(delay)
				}
			}
		}
	}()
}
func (s *Spinner) Start() {
	s.lock.Lock()
	if s.active {
		s.lock.Unlock()
		return
	}
	if s.HideCursor && runtime.GOOS != "windows" {
		// hides the cursor
		fmt.Print("\033[?25l")
	}
	s.active = true
	s.lock.Unlock()

	go func() {
		for {
			for i := 0; i < len(s.chars); i++ {
				select {
				case <-s.stopChan:
					return
				default:
					s.lock.Lock()
					s.erase()
					var outColor string
					if runtime.GOOS == "windows" {
						if s.Writer == os.Stderr {
							outColor = fmt.Sprintf("\r%s%s%s ", s.Prefix, s.chars[i], s.Suffix)
						} else {
							outColor = fmt.Sprintf("\r%s%s%s ", s.Prefix, s.color(s.chars[i]), s.Suffix)
						}
					} else {
						outColor = fmt.Sprintf("%s%s%s ", s.Prefix, s.color(s.chars[i]), s.Suffix)
					}
					outPlain := fmt.Sprintf("%s%s%s ", s.Prefix, s.chars[i], s.Suffix)
					fmt.Fprint(s.Writer, outColor)
					s.lastOutput = outPlain
					delay := s.Delay
					s.lock.Unlock()

					time.Sleep(delay)
				}
			}
		}
	}()
}
func ( s * Spinner ) Start ( ) { s . lock . Lock ( ) if s . active { s . lock . Unlock ( ) return } if s . HideCursor && runtime . GOOS != " " { // hides the cursor fmt . Print ( " \033 " ) } s . active = true s . lock . Unlock ( ) go func ( ) { for { for i := 0 ; i < len ( s . chars ) ; i ++ { select { case <- s . stopChan : return default : s . lock . Lock ( ) s . erase ( ) var outColor string if runtime . GOOS == " " { if s . Writer == os . Stderr { outColor = fmt . Sprintf ( " \r " , s . Prefix , s . chars [ i ] , s . Suffix ) } else { outColor = fmt . Sprintf ( " \r " , s . Prefix , s . color ( s . chars [ i ] ) , s . Suffix ) } } else { outColor = fmt . Sprintf ( " " , s . Prefix , s . color ( s . chars [ i ] ) , s . Suffix ) } outPlain := fmt . Sprintf ( " " , s . Prefix , s . chars [ i ] , s . Suffix ) fmt . Fprint ( s . Writer , outColor ) s . lastOutput = outPlain delay := s . Delay s . lock . Unlock ( ) time . Sleep ( delay ) } } } } ( ) }
// Start will start the indicator
Start will start the indicator