From 39267760ed9bb78c88d17be63fcafcefb767a366 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 12 Nov 2022 00:51:00 -0800 Subject: [PATCH] doc: advise defer Close() on the objectReader --- docs/API.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/API.md b/docs/API.md index c5c90abf0..5c0c32264 100644 --- a/docs/API.md +++ b/docs/API.md @@ -462,11 +462,15 @@ if err != nil { fmt.Println(err) return } +defer object.Close() + localFile, err := os.Create("/tmp/local-file.jpg") if err != nil { fmt.Println(err) return } +defer localFile.Close() + if _, err = io.Copy(localFile, object); err != nil { fmt.Println(err) return