Skip to content

mixed output with Spinner and prints #689

@cgestes

Description

@cgestes
package main

import (
	"time"

	"github.com/pterm/pterm"
)

func fake_prints() {
	for {
		pterm.Println("This is a fake print")
		time.Sleep(time.Second)

	}
}

func main() {

	go fake_prints()

	// Create and start a fork of the default spinner.
	spinnerLiveText, _ := pterm.DefaultSpinner.Start("Doing a lot of stuff...")
	time.Sleep(time.Second)                          // Simulate 2 seconds of processing something.
	spinnerLiveText.UpdateText("It's really much")   // Update spinner text.
	time.Sleep(time.Second)                          // Simulate 2 seconds of processing something.
	spinnerLiveText.UpdateText("We're nearly done!") // Update spinner text.
	time.Sleep(time.Second)                          // Simulate 2 seconds of processing something.
	spinnerLiveText.Success("Finally!")              // Resolve spinner with success message.
}

outputs the following:

➜ go run testprints.go
▀  Doing a lot of stuff... (0s)This is a fake print
▀  Doing a lot of stuff... (1s)This is a fake print
 ▀ We're nearly done!This is a fake print
 ▄ We're nearly done! (3s)This is a fake print
 SUCCESS  Finally!                                                                                                                                                               

expected output:

➜ go run testprints.go
▀  Doing a lot of stuff... (0s)
This is a fake print
▀  Doing a lot of stuff... (1s)
This is a fake print
 ▀ We're nearly done!
This is a fake print
 ▄ We're nearly done! (3s)
This is a fake print
 SUCCESS  Finally!                                                                                                                                                               

I am doing something wrong, or is it a bug? If its a bug can you hint at how to fix it please? :D

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions