summaryrefslogtreecommitdiff
path: root/encode.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@datawire.io>2022-08-30 01:36:46 -0600
committerLuke Shumaker <lukeshu@datawire.io>2022-08-30 01:36:46 -0600
commit8cf459090af5a4e5db0f8c9a4ac21667029f8639 (patch)
tree5e4e38582eaa2a4e4df72bb37548eb6d1764d47d /encode.go
parent325838f35ce90080aa6c892a998d960c06c1c144 (diff)
Allow calling lowmemjson.Encode at the root of EncodeJSON
Diffstat (limited to 'encode.go')
-rw-r--r--encode.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/encode.go b/encode.go
index f93cba4..acef214 100644
--- a/encode.go
+++ b/encode.go
@@ -9,8 +9,10 @@ import (
"encoding"
"encoding/base64"
"encoding/json"
+ "errors"
"fmt"
"io"
+ iofs "io/fs"
"reflect"
"sort"
"strconv"
@@ -130,7 +132,7 @@ func encode(w io.Writer, val reflect.Value, escaper BackslashEscaper, quote bool
SourceFunc: "EncodeJSON",
}})
}
- if err := validator.Close(); err != nil {
+ if err := validator.Close(); err != nil && !errors.Is(err, iofs.ErrClosed) {
panic(encodeError{err})
}