Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 1.25 KB

README.md

File metadata and controls

23 lines (15 loc) · 1.25 KB

handlekeeper

Tag Go Version PkgGoDev Go Report Card License: MIT

handlekeeper is a wrapper for os.OpenFile(). It intends to help applications with keeping track of active textfiles by presenting stable file handles even when the opened files are moved away or deleted. This is achieved by instantly creating a new, empty file in the location of the original file, and re-opening the corresponding filehandle internally.

Usage

hk, _ := handlekeeper.NewHandlekeeper("/some/file.txt")

Now, hk.Handle is an ordinary *os.File and can be used as usual:

Screenshot

Note

The handle only stays stable over delete (or move-away) events on the handled file. Truncating the file (as in logrotate's copy-truncate for example) will still break the handle.