package progress
import "git.sr.ht/~poldi1405/go-indicators/progress"
Package progress allows to easily create a progressbar by simply providing
the total and the completed parts.
The easiest way to get a progressbar is as follows
Code:
Using a custom style is as simple as adding it and changing to it
Code:
Changing the Style is not hard, in fact it's quite easy
Code:
Example¶
{
var p Progress
p.GetBar(275, 346)
}
Example (CustomStyle)¶
{
var p Progress
DefineStyle("my-style", []string{"○", "◔", "◑", "◕", "●"})
p.SetStyle("my-style")
p.GetBar(275, 346)
}
Example (Styled)¶
{
var p Progress
p.SetStyle("parallelogram")
p.GetBar(275, 346)
}
Index ¶
- Variables
- func DefineStyle(name string, characters []string)
- func GetPercentage(parts, total interface{}) (float64, error)
- type Progress
Examples ¶
Variables ¶
var ProgressStyles = map[string][]string{ "double": {" ", "="}, "double-": {" ", "-", "="}, "single": {" ", "-"}, "parallelogram": {"▱", "▰"}, "spaced-blocks": {"▯", "▮"}, "block": {" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█"}, "blocky": {" ", "▖", "▌", "▛", "█"}, "block-gray": {"▒", "█"}, "braille": {"⠀", "⠁", "⠃", "⠇", "⡇", "⣇", "⣧", "⣷", "⣿"}, "line": {"─", "╾", "━"}, "": {" ", "="}, }
ProgressStyles contains the styles of the progressbars. Custom styles can easily be appended and used.
Functions ¶
func DefineStyle ¶
DefineStyle allows registering a custom progress-style to use. If the name is already defined it is overwritten. Directly defining it is possible but not recommended.
func GetPercentage ¶
GetPercentage returns the percentage of a part from a total.
Types ¶
type Progress ¶
type Progress struct { Width int // contains filtered or unexported fields }
Progress contains the settings of a Progressbar.
func (*Progress) GetBar ¶
GetBar returns the string that represents the progressbar in the set style for the given progress. If the parameters are not numeric, the percentage will be 0
func (*Progress) SetStyle ¶
SetStyle sets the style that should be used with the progressbar
Source Files ¶
calculate.go doc.go styles.go type.go
- Version
- v1.2.0 (latest)
- Published
- Apr 16, 2023
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 2 weeks ago –
Tools for package owners.