spingo

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 1 Imported by: 1

README

SpinGO

GitHub Action GitHub license Go Report Card GoDoc

SpinGO is a very basic library for making progress spinners which has no dependencies.

SpinGO is single threaded and meant to be used as a progress indicator, there are other good libraries if you want the spinner to display no matter what's going on.

Table of contents

Demo

Note: Framerate are not fully accurate. Here is another, more accurate demo using asciinema.

Installation

go get -u github.com/talwat/spingo

Usage

spinner := spingo.Spinner{}

for i := 0; i < 100; i++ {
    spinner.DisplaySpinner()
    time.Sleep(40 * time.Millisecond)
}

spinner.End()

Customization

These are fields in the Spinner struct.

Prefix

Prefix to display before the spinner.

Suffix

Suffix to display after the spinner.

SpinnerArt

Spinner art to display, eg. ["/", "|", "\\", "-"]

Documentation

Overview

An extremely basic spinner library

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Spinner

type Spinner struct {
	// Index of the current spinner art, it's fine to not set this when creating a new spinner.
	ArtIndex int

	// Prefix to display before the spinner.
	Prefix string

	// Suffix to display after the spinner.
	Suffix string

	// Spinner art to display,
	//   eg. ["/", "|", "\\", "-"]
	SpinnerArt []string
}

Spinner Struct.

func (*Spinner) DisplaySpinner

func (spinner *Spinner) DisplaySpinner()

Displays the spinners current state. Make sure to call End() when you are done with the spinner. It is not possible to print something in the middle of a spinner spinning or else there will be multiple spinners. For example, do not do this:

spinner.DisplaySpinner()
fmt.Println("Do not do this")
spinner.DisplaySpinner()

func (Spinner) End added in v1.1.0

func (spinner Spinner) End()

Prints a new line to prevent issues with multiple spinners consecutively.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL