diff options
author | Luke Shumaker <lukeshu@datawire.io> | 2022-08-14 20:52:06 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@datawire.io> | 2022-08-16 00:05:24 -0600 |
commit | 54bbd1e59317a6e9658eb8098657078cc8e81979 (patch) | |
tree | 0d7033a0644945dedfe0fca158e0c40864f759f6 /reencode.go | |
parent | 2ae2ebe2a5ac712db6f9221cb1ad8cfa76aad180 (diff) |
wip: Reduce test differences [ci-skip]
- Handle UTF-16 surrogate pairs
- Handle cycles in values
- Handle cycles in types
- Better errors
- Handle case-folding of struct field names
- Allow []byteTypeWithMethods
- Fix struct field-order
- Fix handling of interfaces storing pointers
- Enforce a maximum decode depth
- Validate struct tags
Diffstat (limited to 'reencode.go')
-rw-r--r-- | reencode.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/reencode.go b/reencode.go index 6bd1e48..92e870a 100644 --- a/reencode.go +++ b/reencode.go @@ -20,8 +20,7 @@ type ReEncoder struct { Compact bool // String to use to indent; ignored if Compact is true. Indent string - // String to put before indents, for testing-compat with - // encoding/json only. + // String to put before indents. Prefix string // Returns whether a given character in a string should be // backslash-escaped. The bool argument is whether it was @@ -80,9 +79,9 @@ func (enc *ReEncoder) Write(p []byte) (int, error) { func (enc *ReEncoder) Close() error { if enc.bufLen > 0 { - return &SyntaxError{ + return &DecodeSyntaxError{ Offset: enc.inputPos, - Err: fmt.Sprintf("%v: unflushed unicode garbage: %q", io.ErrUnexpectedEOF, enc.buf[:enc.bufLen]), + Err: fmt.Errorf("%w: unflushed unicode garbage: %q", io.ErrUnexpectedEOF, enc.buf[:enc.bufLen]), } } if _, err := enc.par.HandleEOF(); err != nil { |