From 5f902b89e3dc876ed6d8bba6f27bd000e3cb0d91 Mon Sep 17 00:00:00 2001 From: oliverpool Date: Thu, 2 Mar 2017 15:25:55 +0100 Subject: [PATCH] tmplock must be closed before removal defer are called in LIFO style, so os.Remove was called before tmplock.Close --- vendor/gopkg.in/Acconut/lockfile.v1/lockfile.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vendor/gopkg.in/Acconut/lockfile.v1/lockfile.go b/vendor/gopkg.in/Acconut/lockfile.v1/lockfile.go index bb5c221..6240dbf 100644 --- a/vendor/gopkg.in/Acconut/lockfile.v1/lockfile.go +++ b/vendor/gopkg.in/Acconut/lockfile.v1/lockfile.go @@ -82,8 +82,10 @@ func (l Lockfile) TryLock() error { if err != nil { return err } else { - defer tmplock.Close() - defer os.Remove(tmplock.Name()) + defer func(){ + tmplock.Close() + os.Remove(tmplock.Name()) + }() } _, err = tmplock.WriteString(fmt.Sprintf("%d\n", os.Getpid()))