Library for displaying terminal spinners in Go https://pkg.go.dev/git.brokenmouse.studio/bms/go-spinners
Go to file
ever 4cde045cf4 Initial commit 2024-01-27 15:01:05 +01:00
.markdownlint.json Initial commit 2024-01-27 15:01:05 +01:00
LICENSE Initial commit 2024-01-27 15:01:05 +01:00
README.md Initial commit 2024-01-27 15:01:05 +01:00
go.mod Initial commit 2024-01-27 15:01:05 +01:00
go.sum Initial commit 2024-01-27 15:01:05 +01:00
spinners.go Initial commit 2024-01-27 15:01:05 +01:00

README.md

spinners

Library for displaying terminal spinners in Go.

Usage

package main

import (
	"math/rand"
	"time"

	"git.brokenmouse.studio/bms/go-spinners"
	"git.brokenmouse.studio/bms/go-spinners-ora"
)

func main() {
	spinner := spinners.New(oraSpinners.DOTS)
	spinner.Text = "Spinning ..."

	spinner.Start()

	time.Sleep(time.Second * 2)

	if rand.Intn(2) == 1 {
		spinner.Success()
	} else {
		spinner.Failure()
	}
}

Data

Spinners are easy to create:

spinner := spinners.New(spinners.SpinnerData{
	Frames:   []string{"-", "\\", "|", "/"},
	Interval: time.Millisecond * 100,
})

Alternatively, you can use pre-made spinners:

  • oraSpinners - All spinners from the Node.js package cli-spinners (which ora uses).