progressbar

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: Apache-2.0 Imports: 6 Imported by: 13

README

pgbar

a progess bar write by golang

use

import (
	"github.com/qianlnk/progressbar"
)

	pgb := pgbar.New("多线程进度条")
	pgbar.Println("进度条1")
	b := pgb.NewBar("1st", 20000)
	pgbar.Println("进度条2")
	b2 := pgb.NewBar("2st", 10000)
	pgbar.Println("进度条3")
	b3 := pgb.NewBar("3st", 30000)

	b.SetSpeedSection(900, 100)
	b2.SetSpeedSection(900, 100)
	b3.SetSpeedSection(900, 100)

	pgbar.Println("独立进度条")
	b4 := pgbar.NewBar(0, "4st", 4000)
	var wg sync.WaitGroup
	wg.Add(4)
	go func() {
		defer wg.Done()
		for i := 0; i < 20000; i++ {
			b.Add()
			time.Sleep(time.Second / 2000)
		}
	}()

	go func() {
		defer wg.Done()
		for i := 0; i < 10000; i++ {
			b2.Add()
			time.Sleep(time.Second / 1000)
		}
	}()
	go func() {
		defer wg.Done()
		for i := 0; i < 30000; i++ {
			b3.Add()
			time.Sleep(time.Second / 3000)
		}
	}()

	go func() {
		defer wg.Done()
		for i := 0; i < 4000; i++ {
			b4.Add()
			time.Sleep(time.Second / 300)
		}
	}()
	wg.Wait()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Print

func Print(args ...interface{})

func Printf

func Printf(format string, args ...interface{})

func Println

func Println(args ...interface{})

Types

type Bar

type Bar struct {
	// contains filtered or unexported fields
}

func NewBar

func NewBar(line int, prefix string, total int) *Bar

func (*Bar) Add

func (b *Bar) Add(n ...int)

func (*Bar) SetSpeedSection

func (b *Bar) SetSpeedSection(fast, slow int)

func (*Bar) SetUnit

func (b *Bar) SetUnit(src string, dst string, change int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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