command: f.Close instead of defer

This commit is contained in:
Mitchell Hashimoto 2014-07-27 22:56:55 -07:00
parent 21370b8e23
commit 80ce9ad513
3 changed files with 3 additions and 3 deletions

View File

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

View File

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

View File

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