Skip to content

Commit dfc336f

Browse files
committed
fix: response close
1 parent f98f1bc commit dfc336f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

main.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func sendPVEStatusToTelegram(text string, temp float64, conf *Config) error {
126126
if err != nil {
127127
return err
128128
}
129-
_ = resp.Body.Close()
129+
defer resp.Body.Close()
130130

131131
if resp.StatusCode != http.StatusOK {
132132
return fmt.Errorf("request failed with status code: %s", resp.Status)
@@ -169,10 +169,7 @@ func pinMessageToTelegram(conf *Config, messageId int64) error {
169169
if err != nil {
170170
return err
171171
}
172-
err = resp.Body.Close()
173-
if err != nil {
174-
return err
175-
}
172+
defer resp.Body.Close()
176173

177174
// pin the message
178175
data = map[string]interface{}{
@@ -193,7 +190,9 @@ func pinMessageToTelegram(conf *Config, messageId int64) error {
193190
if err != nil {
194191
return err
195192
}
196-
return resp.Body.Close()
193+
defer resp.Body.Close()
194+
195+
return nil
197196
}
198197

199198
func loadConfig(path string) (*Config, error) {

0 commit comments

Comments
 (0)