From 37b0e0272be951f57115a35738df87c714e0ef4a Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Sat, 15 Sep 2018 12:17:34 -0400 Subject: [PATCH] Add an explicit Close function to implement io.Closer --- flock.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/flock.go b/flock.go index 867c765..89d6254 100644 --- a/flock.go +++ b/flock.go @@ -39,6 +39,14 @@ func NewFlock(path string) *Flock { return &Flock{path: path} } +// Close is equivalent to calling Unlock. +// +// This will release the lock and close the underlying file descriptor. +// It will not remove the file from disk, that's up to your application. +func (f *Flock) Close() error { + return f.Unlock() +} + // Path is a function to return the path as provided in NewFlock(). func (f *Flock) Path() string { return f.path