Replace with anonymoud functions (#53386)

This commit is contained in:
Dimitris Sotirakis 2022-08-08 15:09:52 +03:00 committed by GitHub
parent aee2856907
commit ee8966344d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,7 +99,11 @@ func BuildManifest(ctx context.Context, dpath string, signingAdmin bool) error {
if err != nil {
return fmt.Errorf("failed to get signed manifest from Grafana API: %w", err)
}
defer logError(resp.Body.Close())
defer func() {
if err := resp.Body.Close(); err != nil {
log.Println("failed to close response body, err: %w", err)
}
}()
if resp.StatusCode != 200 {
msg, err := ioutil.ReadAll(resp.Body)
if err != nil {
@ -114,7 +118,11 @@ func BuildManifest(ctx context.Context, dpath string, signingAdmin bool) error {
if err != nil {
return fmt.Errorf("failed to create %s: %w", manifestPath, err)
}
defer logCloseError(f.Close)
defer func() {
if err := f.Close(); err != nil {
log.Println("failed to close file, err: %w", err)
}
}()
if _, err := io.Copy(f, resp.Body); err != nil {
return fmt.Errorf("failed to write %s: %w", manifestPath, err)
}