mirror of
https://github.com/nxshock/progressmessage.git
synced 2025-07-01 00:13:42 +05:00
Create README.md
This commit is contained in:
parent
7bcf98ba3e
commit
63cec26e1e
1 changed files with 40 additions and 0 deletions
40
README.md
Normal file
40
README.md
Normal file
|
@ -0,0 +1,40 @@
|
|||
# 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