spinner.go
func (s *Spinner) erase() {
	n := utf8.RuneCountInString(s.lastOutput)
	if runtime.GOOS == "windows" {
		clearString := "\r"
		for i := 0; i < n; i++ {
			clearString += " "
		}
		fmt.Fprintf(s.Writer, clearString)
		return
	}
	del, _ := hex.DecodeString("7f")
	for _, c := range []string{
		"\b",
		string(del),
		"\b",
		"\033[K", // for macOS Terminal
	} {
		for i := 0; i < n; i++ {
			fmt.Fprintf(s.Writer, c)
		}
	}
	s.lastOutput = ""
}
func (s *Spinner) erase() {
	n := utf8.RuneCountInString(s.lastOutput)
	if runtime.GOOS == "windows" {
		clearString := "\r"
		for i := 0; i < n; i++ {
			clearString += " "
		}
		fmt.Fprintf(s.Writer, clearString)
		return
	}
	del, _ := hex.DecodeString("7f")
	for _, c := range []string{
		"\b",
		string(del),
		"\b",
		"\033[K", // for macOS Terminal
	} {
		for i := 0; i < n; i++ {
			fmt.Fprintf(s.Writer, c)
		}
	}
	s.lastOutput = ""
}
func ( s * Spinner ) erase ( ) { n := utf8 . RuneCountInString ( s . lastOutput ) if runtime . GOOS == " " { clearString := " \r " for i := 0 ; i < n ; i ++ { clearString += " " } fmt . Fprintf ( s . Writer , clearString ) return } del , _ := hex . DecodeString ( " " ) for _ , c := range [ ] string { " \b " , string ( del ) , " \b " , " \033 " , // for macOS Terminal } { for i := 0 ; i < n ; i ++ { fmt . Fprintf ( s . Writer , c ) } } s . lastOutput = " " }
// erase deletes written characters
//
// Caller must already hold s.lock.
erase deletes written characters Caller must already hold s . lock .