Skip to content

Commit 0a5c8ec

Browse files
author
Jeff McCormick
committed
fix defer stmt ordering
1 parent 79fa96c commit 0a5c8ec

File tree

17 files changed

+28
-27
lines changed

17 files changed

+28
-27
lines changed

pgo/api/backrest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ func ShowBackrest(httpclient *http.Client, arg, selector string, SessionCredenti
3939

4040
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
4141
resp, err := httpclient.Do(req)
42-
defer resp.Body.Close()
4342
if err != nil {
4443
fmt.Println("Error: Do: ", err)
4544
return response, err
4645
}
46+
defer resp.Body.Close()
4747
log.Debugf("%v\n", resp)
4848
err = StatusCheck(resp)
4949
if err != nil {
@@ -79,10 +79,10 @@ func CreateBackrestBackup(httpclient *http.Client, SessionCredentials *msgs.Basi
7979
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
8080

8181
resp, err := httpclient.Do(req)
82-
defer resp.Body.Close()
8382
if err != nil {
8483
return response, err
8584
}
85+
defer resp.Body.Close()
8686

8787
log.Debugf("%v\n", resp)
8888
err = StatusCheck(resp)

pgo/api/backup.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ func ShowBackup(httpclient *http.Client, arg string, SessionCredentials *msgs.Ba
4040

4141
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
4242
resp, err := httpclient.Do(req)
43-
defer resp.Body.Close()
4443
if err != nil {
4544
fmt.Println("Error: Do: ", err)
4645
return response, err
4746
}
47+
defer resp.Body.Close()
4848
log.Debugf("%v\n", resp)
4949
err = StatusCheck(resp)
5050
if err != nil {
@@ -75,11 +75,11 @@ func DeleteBackup(httpclient *http.Client, arg string, SessionCredentials *msgs.
7575

7676
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
7777
resp, err := httpclient.Do(req)
78-
defer resp.Body.Close()
7978
if err != nil {
8079
fmt.Println("Error: Do: ", err)
8180
return response, err
8281
}
82+
defer resp.Body.Close()
8383
log.Debugf("%v\n", resp)
8484
err = StatusCheck(resp)
8585
if err != nil {
@@ -114,10 +114,10 @@ func CreateBackup(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCre
114114
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
115115

116116
resp, err := httpclient.Do(req)
117-
defer resp.Body.Close()
118117
if err != nil {
119118
return response, err
120119
}
120+
defer resp.Body.Close()
121121

122122
log.Debugf("%v\n", resp)
123123
err = StatusCheck(resp)

pgo/api/cluster.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,12 @@ func CreateCluster(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCr
123123
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
124124

125125
resp, err := httpclient.Do(req)
126-
defer resp.Body.Close()
127126
if err != nil {
128127
return response, err
129128
}
130129

130+
defer resp.Body.Close()
131+
131132
log.Debugf("%v\n", resp)
132133
err = StatusCheck(resp)
133134
if err != nil {

pgo/api/failover.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ func CreateFailover(httpclient *http.Client, SessionCredentials *msgs.BasicAuthC
4242
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
4343

4444
resp, err := httpclient.Do(req)
45-
defer resp.Body.Close()
4645
if err != nil {
4746
return response, err
4847
}
48+
defer resp.Body.Close()
4949

5050
log.Debugf("%v\n", resp)
5151
err = StatusCheck(resp)

pgo/api/ingest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ func ShowIngest(httpclient *http.Client, arg string, SessionCredentials *msgs.Ba
3939

4040
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
4141
resp, err := httpclient.Do(req)
42-
defer resp.Body.Close()
4342
if err != nil {
4443
fmt.Println("Error: Do: ", err)
4544
return response, err
4645
}
46+
defer resp.Body.Close()
4747
log.Debugf("%v\n", resp)
4848
err = StatusCheck(resp)
4949
if err != nil {
@@ -76,10 +76,10 @@ func CreateIngest(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCre
7676
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
7777

7878
resp, err := httpclient.Do(req)
79-
defer resp.Body.Close()
8079
if err != nil {
8180
return response, err
8281
}
82+
defer resp.Body.Close()
8383

8484
log.Debugf("%v\n", resp)
8585
err = StatusCheck(resp)

pgo/api/label.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ func LabelClusters(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCr
4040
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
4141

4242
resp, err := httpclient.Do(req)
43-
defer resp.Body.Close()
4443
if err != nil {
4544
return response, err
4645
}
46+
defer resp.Body.Close()
4747

4848
log.Debugf("%v\n", resp)
4949
err = StatusCheck(resp)

pgo/api/load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ func CreateLoad(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCrede
4040
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
4141

4242
resp, err := httpclient.Do(req)
43-
defer resp.Body.Close()
4443
if err != nil {
4544
return response, err
4645
}
46+
defer resp.Body.Close()
4747

4848
log.Debugf("%v\n", resp)
4949
err = StatusCheck(resp)

pgo/api/pgpool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ func CreatePgpool(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCre
4040
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
4141

4242
resp, err := httpclient.Do(req)
43-
defer resp.Body.Close()
4443
if err != nil {
4544
return response, err
4645
}
46+
defer resp.Body.Close()
4747

4848
log.Debugf("%v\n", resp)
4949
err = StatusCheck(resp)
@@ -77,10 +77,10 @@ func DeletePgpool(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCre
7777
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
7878

7979
resp, err := httpclient.Do(req)
80-
defer resp.Body.Close()
8180
if err != nil {
8281
return response, err
8382
}
83+
defer resp.Body.Close()
8484

8585
log.Debugf("%v\n", resp)
8686
err = StatusCheck(resp)

pgo/api/policy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ func ShowPolicy(httpclient *http.Client, arg string, SessionCredentials *msgs.Ba
3939

4040
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
4141
resp, err := httpclient.Do(req)
42-
defer resp.Body.Close()
4342
if err != nil {
4443
fmt.Println("Error: Do: ", err)
4544
return response, err
4645
}
46+
defer resp.Body.Close()
4747
log.Debugf("%v\n", resp)
4848
err = StatusCheck(resp)
4949
if err != nil {
@@ -76,10 +76,10 @@ func CreatePolicy(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCre
7676
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
7777

7878
resp, err := httpclient.Do(req)
79-
defer resp.Body.Close()
8079
if err != nil {
8180
return response, err
8281
}
82+
defer resp.Body.Close()
8383

8484
log.Debugf("%v\n", resp)
8585
err = StatusCheck(resp)
@@ -152,10 +152,10 @@ func ApplyPolicy(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCred
152152
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
153153

154154
resp, err := httpclient.Do(req)
155-
defer resp.Body.Close()
156155
if err != nil {
157156
return response, err
158157
}
158+
defer resp.Body.Close()
159159

160160
log.Debugf("%v\n", resp)
161161
err = StatusCheck(resp)

pgo/api/pvc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ func ShowPVC(httpclient *http.Client, pvcName, pvcRoot string, SessionCredential
3838

3939
req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password)
4040
resp, err := httpclient.Do(req)
41-
defer resp.Body.Close()
4241
if err != nil {
4342
fmt.Println("Error: Do: ", err)
4443
return response, err
4544
}
45+
defer resp.Body.Close()
4646
log.Debugf("%v\n", resp)
4747
err = StatusCheck(resp)
4848
if err != nil {

0 commit comments

Comments
 (0)