command: f.Close instead of defer
This commit is contained in:
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…
Reference in New Issue