From 8879dba851881f3a6d7c4597ae7933dfbfeb31ea Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Mon, 11 Nov 2019 16:46:12 -0500 Subject: [PATCH] remove out file if packing panics --- cmd/pkger/cmds/pack.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/pkger/cmds/pack.go b/cmd/pkger/cmds/pack.go index d09792b..bc056a9 100644 --- a/cmd/pkger/cmds/pack.go +++ b/cmd/pkger/cmds/pack.go @@ -125,6 +125,11 @@ func (e *packCmd) Flags() *flag.FlagSet { func Package(out string, decls parser.Decls) error { os.RemoveAll(out) + defer func() { + if err := recover(); err != nil { + os.RemoveAll(out) + } + }() f, err := os.Create(out) if err != nil {