Skip to content

tom-draper/go-spinners

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Spinners

A collection of progress spinners for Go.

SpinnerDemo

Installation

go get github.com/tom-draper/go-spinners

Usage

Import the package into your project.

import spinners "github.com/tom-draper/go-spinners"

Create a spinner with the Spinner function, passing in the name of the spinner.

s := spinners.Spinner("line")
s.Start()
time.Sleep(time.Second * 5) // Perform computation
s.Stop()

Prefix text can be specified with SetPrefix to appear before the spinner animation. Similarly, a postfix can be set with SetPostfix.

s := spinners.Spinner("flip")
s.Start()
s.SetPrefix("Loading")
time.Sleep(time.Second * 5) // Perform computation
s.Stop()

The animation speed can be modified using the SetDelay function. The default delay is 100 milliseconds.

s := spinners.Spinner("dots2")
s.SetDelay(time.Millisecond * 500)
s.Start()
time.Sleep(time.Second * 5) // Perform computation
s.Stop()