Skip to content

Spinner may not start/restart properly when stopped often #101

@alebcay

Description

@alebcay

Consider the following basic program:

package main

import (
	"fmt"
	"time"

	"github.com/briandowns/spinner"
)

func main() {
	mySpinner := spinner.New(spinner.CharSets[11], 100 * time.Millisecond)
	mySpinner.Suffix = " Starting spinner"
	mySpinner.Start()
	time.Sleep(500 * time.Millisecond)

	i := 0
	for {
		mySpinner.Stop()
		fmt.Printf("This is message #%d\n", i)
		mySpinner.Restart()
		i += 1
		time.Sleep(500 * time.Millisecond)
	}
}

The expected behavior is that the fmt.Printf(...) lines are printed one by one, with just the spinner running below it. However, after some time (usually less than printing 100 lines in my limited testing), the spinner no longer appears below the output of invocations of fmt.Printf(...) and all that appears is just the lines being printed.

I've also tried wrapping the Restart() call like so:

for ok := true; ok; ok = !mySpinner.Active() {
    mySpinner.Restart()
}

but this doesn't seem to fix the issue - the execution proceeds without the spinner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions