Skip to content

A go library to make it easier to write filters that modify a file in-place.

License

Notifications You must be signed in to change notification settings

kentquirk/rewriter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

rewriter

The rewriter package is designed to make it easy to write filters that operate on a file.

It creates an object that reads from the input file and writes to a temporary file.

When you call Close(), both files are closed and the output replaces the input.

If you call Abort(), the output file is deleted and the input file is unaffected.

The File object implements io.ReadWriteCloser.

usage:

f, _ := rewriter.New("existingFile.txt")
err := someFilter(f) // both reads and writes f
if err != nil {
    f.Abort()   // existingFile.txt is unchanged
    return err
}
f.Close()  // existingFile.txt is safely replaced

About

A go library to make it easier to write filters that modify a file in-place.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages