https://github.com/rosylilly/pio
io with progress
https://github.com/rosylilly/pio
golang golang-library io
Last synced: 2 months ago
JSON representation
io with progress
- Host: GitHub
- URL: https://github.com/rosylilly/pio
- Owner: rosylilly
- License: mit
- Created: 2021-04-08T07:45:43.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-08T10:14:01.000Z (about 5 years ago)
- Last Synced: 2025-10-19T10:35:54.928Z (8 months ago)
- Topics: golang, golang-library, io
- Language: Go
- Homepage: https://pkg.go.dev/github.com/rosylilly/pio
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pio - io with progress
[](https://pkg.go.dev/github.com/rosylilly/pio)
[](https://github.com/rosylilly/pio/actions/workflows/test.yml)
[](https://codecov.io/gh/rosylilly/pio)
## Example
```golang
package main
import (
"bytes"
"errors"
"fmt"
"io"
"log"
"os"
"github.com/rosylilly/pio"
)
func main() {
file, err := os.Open("README.md")
if err != nil {
log.Fatalln(err)
}
logger := log.New(os.Stdout, "", log.Ltime)
reader, err := pio.NewReader(file, pio.WithLogger(logger))
if err != nil {
log.Fatalln(err)
}
buffer := bytes.NewBuffer([]byte{})
for {
_, err := io.CopyN(buffer, reader, 100)
if err != nil {
if errors.Is(err, io.EOF) {
break
} else {
log.Fatalln(err)
}
}
}
fmt.Println(buffer.String())
}
```
[](https://asciinema.org/a/405916)
## License
[MIT License](https://github.com/rosylilly/pio/blob/main/LICENSE)