progressbar

package
v1.21.8 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: Apache-2.0 Imports: 5 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 ...any)

func Printf

func Printf(format string, args ...any)

func Println

func Println(args ...any)

Types

type Bar

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

Bar 进度条

func NewBar

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

func (*Bar) Add

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

Add 进度条前进, 同时也会触发其它信号

func (*Bar) SetPrefix added in v1.19.6

func (b *Bar) SetPrefix(prefix string)

SetPrefix 设置进度条前端文字

func (*Bar) SetSpeedSection

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

func (*Bar) SetUnit

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

func (*Bar) Wait added in v1.17.6

func (b *Bar) Wait()

Wait 等待进度条刷新run协程结束

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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