mirror of
https://github.com/nxshock/progressmessage.git
synced 2025-07-03 00:33:42 +05:00
Compare commits
No commits in common. "main" and "v0.1" have entirely different histories.
1 changed files with 0 additions and 40 deletions
40
README.md
40
README.md
|
@ -1,40 +0,0 @@
|
||||||
# processmessage
|
|
||||||
|
|
||||||
Go library for displaying progress messages.
|
|
||||||
|
|
||||||
## Usage example
|
|
||||||
|
|
||||||
```go
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/nxshock/progressmessage"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// Create new message
|
|
||||||
pm := progressmessage.New("Progress: %d%%...")
|
|
||||||
|
|
||||||
// Start message display
|
|
||||||
pm.Start()
|
|
||||||
|
|
||||||
// Let's do some job
|
|
||||||
for i := 0; i < 100; i++ {
|
|
||||||
// Simulate some work
|
|
||||||
time.Sleep(time.Second / 5)
|
|
||||||
|
|
||||||
// Update progress variables in same order as specified on creating the message
|
|
||||||
pm.Update(i + 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop message display
|
|
||||||
pm.Stop()
|
|
||||||
|
|
||||||
// Cursor stays in progress message position so you can display result message manually
|
|
||||||
fmt.Fprintln(os.Stderr, "\rProcessing finished.")
|
|
||||||
}
|
|
||||||
```
|
|
Loading…
Add table
Add a link
Reference in a new issue