[golang]golang如何覆盖输出console,实现进度条
package main import(
"fmt"
"os"
"time"
) func main(){
for i :=;i!=;i=i+{
fmt.Fprintf(os.Stdout,"result is %d\r",i)
time.Sleep(time.Second*)
}
fmt.Println("Over")
}
golang一个骚气的进度提示库
spinner is a simple package to add a spinner / progress indicator to any terminal application. Examples can be found below as well as full examples in the examples directory.
For more detail about the library and its features, reference your local godoc once installed.
Contributions welcome!
安装
go get -u -v github.com/briandowns/spinner
下面是效果图
(Numbered by their slice index)
0 | ←↖↑↗→↘↓↙ | |
1 | ▁▃▄▅▆▇█▇▆▅▄▃▁ | |
2 | ▖▘▝▗ | |
3 | ┤┘┴└├┌┬┐ | |
4 | ◢◣◤◥ | |
5 | ◰◳◲◱ | |
6 | ◴◷◶◵ | |
7 | ◐◓◑◒ | |
8 | .oO@* | |
9 | ``` | /-``` |
10 | ◡◡⊙⊙◠◠ | |
11 | ⣾⣽⣻⢿⡿⣟⣯⣷ | |
12 | >))'> >))'> >))'> >))'> >))'> <'((< <'((< <'((< | |
13 | ⠁⠂⠄⡀⢀⠠⠐⠈ | |
14 | ⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏ | |
15 | abcdefghijklmnopqrstuvwxyz | |
16 | ▉▊▋▌▍▎▏▎▍▌▋▊▉ | |
17 | ■□▪▫ | |
18 | ←↑→↓ | |
19 | ╫╪ | |
20 | ⇐⇖⇑⇗⇒⇘⇓⇙ | |
21 | ⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈ | |
22 | ⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈ | |
23 | ⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁ | |
24 | ⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋ | |
25 | ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン | |
26 | . .. ... | |
27 | ▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▏▎▍▌▋▊▉█▇▆▅▄▃▂▁ | |
28 | .oO°Oo. | |
29 | +x | |
30 | v<^> | |
31 | >>---> >>---> >>---> >>---> >>---> <---<< <---<< <---<< <---<< <---<< | |
32 | ``` | |
33 | [] [=] [==] [===] [====] [=====] [======] [=======] [========] [=========] [==========] | |
34 | (*---------) (-*--------) (--*-------) (---*------) (----*-----) (-----*----) (------*---) (-------*--) (--------*-) (---------*) | |
35 | █▒▒▒▒▒▒▒▒▒ ███▒▒▒▒▒▒▒ █████▒▒▒▒▒ ███████▒▒▒ ██████████ | |
36 | [ ] [=> ] [===> ] [=====> ] [======> ] [========> ] [==========> ] [============> ] [==============> ] [================> ] [==================> ] [===================>] | |
37 |
|