Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tom-draper/go-spinners
A collection of progress spinners for Go.
https://github.com/tom-draper/go-spinners
animation cli-spinner cli-spinners go golang loading loading-animations loading-spinner progress-bar spinner spinners
Last synced: 6 days ago
JSON representation
A collection of progress spinners for Go.
- Host: GitHub
- URL: https://github.com/tom-draper/go-spinners
- Owner: tom-draper
- Created: 2022-07-18T17:56:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-29T17:10:17.000Z (over 2 years ago)
- Last Synced: 2024-11-08T10:05:53.321Z (about 2 months ago)
- Topics: animation, cli-spinner, cli-spinners, go, golang, loading, loading-animations, loading-spinner, progress-bar, spinner, spinners
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go Spinners
A collection of progress spinners for Go.![SpinnerDemo](https://user-images.githubusercontent.com/41476809/181807553-316d0f69-426a-4559-9268-d50a8ae9d611.gif)
## Installation
```bash
go get github.com/tom-draper/go-spinners
```## Usage
Import the package into your project.
```go
import spinners "github.com/tom-draper/go-spinners"
```Create a spinner with the
Spinner
function, passing in the name of the spinner.```go
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 withSetPostfix
.```go
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.```go
s := spinners.Spinner("dots2")
s.SetDelay(time.Millisecond * 500)
s.Start()
time.Sleep(time.Second * 5) // Perform computation
s.Stop()
```