Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alebcay opened this issue Jul 8, 2020 · 3 comments
Open

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

alebcay opened this issue Jul 8, 2020 · 3 comments

Comments

@alebcay
Copy link

alebcay commented Jul 8, 2020

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.

@briandowns
Copy link
Owner

Thanks for filing this. What version are you using?

@alebcay
Copy link
Author

alebcay commented Jul 8, 2020

1.11.1 I believe (whatever import "github.com/briandowns/spinner" got me today), on darwin/amd64.

@theckman
Copy link

@alebcay After seeing some of the challenges with this project I've created an alternative spinner, and have been trying to see if mine suffers from any of the same limitations as this one. I wanted to reach out to see if you might be willing to try my spinner to see if you can reproduce this issue there, and if so raise an issue: https://github.com/theckman/yacspin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants