From 80ce9ad5135bee8672b6534e9198a9ecbb1b62a5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 27 Jul 2014 22:56:55 -0700 Subject: [PATCH] command: f.Close instead of defer --- command/apply.go | 2 +- command/plan.go | 2 +- command/refresh.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/command/apply.go b/command/apply.go index 941d1db88..7553da047 100644 --- a/command/apply.go +++ b/command/apply.go @@ -82,8 +82,8 @@ func (c *ApplyCommand) Run(args []string) int { log.Printf("[INFO] Writing backup state to: %s", backupPath) f, err := os.Create(backupPath) if err == nil { - defer f.Close() err = terraform.WriteState(c.State, f) + f.Close() } if err != nil { c.Ui.Error(fmt.Sprintf("Error writing backup state file: %s", err)) diff --git a/command/plan.go b/command/plan.go index 32ee31527..67edae234 100644 --- a/command/plan.go +++ b/command/plan.go @@ -80,8 +80,8 @@ func (c *PlanCommand) Run(args []string) int { log.Printf("[INFO] Writing backup state to: %s", backupPath) f, err := os.Create(backupPath) if err == nil { - defer f.Close() err = terraform.WriteState(c.State, f) + f.Close() } if err != nil { c.Ui.Error(fmt.Sprintf("Error writing backup state file: %s", err)) diff --git a/command/refresh.go b/command/refresh.go index f3038f96a..69ff45601 100644 --- a/command/refresh.go +++ b/command/refresh.go @@ -98,8 +98,8 @@ func (c *RefreshCommand) Run(args []string) int { log.Printf("[INFO] Writing backup state to: %s", backupPath) f, err := os.Create(backupPath) if err == nil { - defer f.Close() err = terraform.WriteState(c.State, f) + f.Close() } if err != nil { c.Ui.Error(fmt.Sprintf("Error writing backup state file: %s", err))