Platform independent Go module to print spinners on Terminal/ cmd
MIT License
Platform independent Go module to print spinners on Terminal/ cmd
Have 80+ spinners, Segregated into ASCII(id: 1-999) and Unicode(id >= 1000) spinners
Custom (user-defined) spinners
Support rich color rendering output for the spinners (in both 16bit colors and Hexcodes)
Colors compatible with Windows system.
Universal and Stable API method
Made with concurrency handling in mind
Complete documentation of the API is hosted at pkg.go.dev
Below Tables show spinners with their IDs. Use it as reference
These are simple examples. For more Indepth uses refer the API documentation hosted at pkg.go.dev
The following code creates a new spinner and uses it
package main
import (
"time"
"log"
spinner "github.com/Yash-Handa/spinner"
)
func main() {
sp, err := spinner.New(4, 50 * time.Millisecond, spinner.Cyan, spinner.Normal)
if err != nil {
log.Fatal(err)
}
sp.SetPostText(" Loading Content")
sp.SetDoneText("Hurray spinner worked\n")
sp.Start() // the spinner starts
time.Sleep(3 * time.Second) // after 3 seconds
sp.SetColor(spinner.Magenta, "") // use previous background color
sp.SetInterval(100 * time.Millisecond)
sp.SetPostText(" The color and speed Changed !!")
time.Sleep(3 * time.Second)
sp.Stop() // the spinner stops
}
The following code creates a custom spinner using user defined symbols.
package main
import (
"time"
"log"
spinner "github.com/Yash-Handa/spinner"
)
func main() {
symbols := []string{"N ", "IN ", "PIN ", "SPIN", " SPI", " SP", " S", " "}
sp, err := spinner.Custom(symbols, 0, spinner.Red, spinner.Normal)
if err != nil {
log.Fatal(err)
}
sp.SetPostText(" A custom spinner")
sp.Start() // the spinner starts
time.Sleep(3 * time.Second) // after 3 seconds the color changes to lime green
sp.SetColor("00e600", spinner.HexBgNormal)
// spinner.HexBgNormal is used with Hex foreground to indicate that no background color to be used
sp.SetPostText(" The color Changed !!")
time.Sleep(3 * time.Second)
sp.Stop() // the spinner stops
}
The Project is Open Sourced under MIT License and will always welcomes Pull Request. Please read CONTRIBUTING.md.