From b709b206876a9cf8e7a4531963610cb5cb9589de Mon Sep 17 00:00:00 2001 From: fengjun2016 Date: Thu, 26 Dec 2024 11:22:55 +0800 Subject: [PATCH] [fix] file fd leak --- internal/cmd/release/main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/cmd/release/main.go b/internal/cmd/release/main.go index 3dbed864bb..25b7d0d746 100644 --- a/internal/cmd/release/main.go +++ b/internal/cmd/release/main.go @@ -96,12 +96,13 @@ func gitHubOutputReleaseURLIfAvailable(url string) { return } - if _, err := f.WriteString(fmt.Sprintf("RELEASE_URL=%s\n", url)); err != nil { - log.Fatalln(err) - return - } + defer func() { + if err := f.Close(); err != nil { + log.Fatalln(err) + } + }() - if err := f.Close(); err != nil { + if _, err := f.WriteString(fmt.Sprintf("RELEASE_URL=%s\n", url)); err != nil { log.Fatalln(err) return }