command: f.Close instead of defer

pull/43/head
Mitchell Hashimoto 12 years ago
parent 21370b8e23
commit 80ce9ad513

@ -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))

@ -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))

@ -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))

Loading…
Cancel
Save