fix: ignore ErrClosed in deferred func

This commit is contained in:
wpetit 2022-08-01 17:13:56 +02:00 committed by Bornholm
parent 1c770b7413
commit 6b1fd647e1
1 changed files with 2 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"io" "io"
"net/url" "net/url"
"os"
encjson "encoding/json" encjson "encoding/json"
@ -173,7 +174,7 @@ func outputValues(ctx *cli.Context, values interface{}) error {
} }
defer func() { defer func() {
if err := writer.Close(); err != nil { if err := writer.Close(); err != nil && !errors.Is(err, os.ErrClosed) {
panic(errors.WithStack(err)) panic(errors.WithStack(err))
} }
}() }()