From e85509c466a3519066bbd040beb70f927095a473 Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Wed, 13 Nov 2019 05:18:20 -0800 Subject: [PATCH] command: error handling before file close (#6681) --- command/helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command/helpers.go b/command/helpers.go index 364c73929..38b986870 100644 --- a/command/helpers.go +++ b/command/helpers.go @@ -421,10 +421,10 @@ func (j *JobGetter) ApiJob(jpath string) (*api.Job, error) { return nil, fmt.Errorf("Error getting jobfile from %q: %v", jpath, err) } else { file, err := os.Open(job.Name()) - defer file.Close() if err != nil { return nil, fmt.Errorf("Error opening file %q: %v", jpath, err) } + defer file.Close() jobfile = file } }