Skip to content
/ ctxio Public

`ctxio` gives `io.copy` operations the ability to cancel with context and retrieve progress data.

License

Notifications You must be signed in to change notification settings

binalyze/ctxio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ctxio

The ctxio package gives golang io.copy operations the ability to terminate with context and retrieve progress data.

Install

  go get github.com/binalyze/ctxio

Usage

Here is an example to use ctxio with io.copy operation. You can find more examples in test files.

Writer

srcFile, err := os.Open("sourcefile.log")
dstFile, err := os.Create("destinationFile.log")

progressFn := func(n int64) {
    // Here you can send progress to API etc.
}

w := NewWriter(ctx, dstFile, progressFn)

written, err := io.Copy(w, file)

Roadmap

  • Add io.Reader support just like io.Writer

Related Projects

About

`ctxio` gives `io.copy` operations the ability to cancel with context and retrieve progress data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages