progressbar 另一个进度条
最后更新于:2022-04-02 02:39:15
[TOC]
> [schollz/progressbar](https://github.com/schollz/progressbar)
## 安装
`go get -u github.com/schollz/progressbar/v2`
## 实例
### 基础
```
bar := progressbar.New(100)
for i := 0; i < 100; i++ {
bar.Add(1)
time.Sleep(10 * time.Millisecond)
}
```
```
100% |████████████████████████████████████████| [1s:0s]
```
### 使用自定义样式
```
bar := NewOptions(
10,
OptionSetTheme(Theme{Saucer: "#", SaucerPadding: "-", BarStart: ">", BarEnd: "<"}),
OptionSetWidth(10),
OptionSetWriter(&buf),
)
bar.Add(5)
result := strings.TrimSpace(buf.String())
````
```
50% >#####-----< [0s:0s]
```
';