Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

git.sr.ht/~liliace/pogs

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git.sr.ht/~liliace/pogs

  • v1.0.0
  • Go
  • Socket score

Version published
Created
Source

pogs Go Documentation

A thread-safe go library for displaying multiple progress bars in unix terminals.

Progress bars typically clear and redraw the line as they update. Using a progress bar library not designed to display multiple progress bars to do so would cause each progress bar to rewrite each other.

The pogs library supports displaying multiple progress bars by moving and keeping track of the cursor position.

Additionally, the pogs library separates the method for creating a progress bar into NewBar and Start to support use cases where the jobs of the progress bar may complete before we know the number of the jobs (see example below).

Installation

The pogs library depends on golang.org/x/sys, which hangs forever if you have GOPROXY=direct in your environment. Install with the cache proxy instead:

GOPROXY="" go get -u git.sr.ht/~liliace/pogs

Example

In this example, we don't know the size of each progress bar until after we have finished each inner loop. We are still able to advance the progress bar data with bars.Add before displaying it with bars.Start.

bars, err := pogs.NewBars()
if err != nil {
	log.Fatal(err)
}

for _ = range 5 {
	id, _ := bars.NewBar()
	size := 0
	// consider root a pre-defined node of some linked-list
	for curr := root; curr != nil; curr = curr.Next {
		bars.Add(id)
		size += 1
	}
	bars.Start(id, size)
}
bars.Done()

The id returned by bars.NewBar is the id-th bar created, so the loop above can be simplified to:

for i = range 5 {
	bars.NewBar()
	size := 0
	for curr := root; curr != nil; curr = curr.Next {
		bars.Add(i)
		size += 1
	}
	bars.Start(i, size)
}

FAQs

Package last updated on 11 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc