Releases: fxamacker/cbor
v2.7.0
v2.7.0 (June 23, 2024)
v2.7.0 adds features and improvements that help large projects (e.g. Kubernetes) use CBOR as an alternative to JSON and Protocol Buffers. Other improvements include speedups, improved memory use, bug fixes, decoding/encoding options, etc. Passed 5+ billion execs fuzzing.
Special thanks to @benluddy for contributing features, optimizations, improvements, bug fixes, and discussions! 👍
⭐ Features and Optimizations
- Add decoding option TimeTagToAny to produce RFC3339 when decoding time into interface{} by @ssuriyan7 in #506
- Bypass sorting overhead for single-entry maps. by @benluddy in #516
- Add decode option to allow rejecting inputs that contain certain simple values. by @benluddy in #481
- Allow rejection of NaN and Inf float values on encode and decode. by @benluddy in #513
- Add SortMode to encode struct fields in a less predictable order. by @benluddy in #515
- Add a decoding option to allow decoding byte string into time.Time. by @benluddy in #524
- Encode structs directly to output buffer. by @benluddy in #519
- Support automatic conversion between text and binary string representations by @benluddy in #476
- Add a method for marshaling directly into a user-provided buffer. by @benluddy in #521
- Add options to disable BinaryMarshaler/BinaryUnmarshaler support. by @benluddy in #526
- Add option to reject decoding bignum tags and encoding big.Int. by @benluddy in #527
- Improve speed & memory use for Diagnose() and DiagnoseFirst() by @benluddy in #533
- Refactor sorted map encode to use fewer buffers for nested maps. by @benluddy in #537
- Allow user to specify buffer by adding
cbor.MarshalToBuffer()
,UserBufferEncMode
interface, etc. by @fxamacker in #553
🛠 Improvements
Most improvements focused on fixing or updating new features. See 🐞 Bug Fixes section for fixes to features already released.
- Refactor to reuse functions and improve code coverage by @fxamacker in #531
- Fix invalid RFC 3339 in TimeTagToAny (unreleased new feature) by @benluddy in #540
- Refactor and improve code by @fxamacker in #542
- Use "cbor:" prefixed error msg when decoding with non-default TimeTagToAnyMode setting by @fxamacker in #544
- Disable conflicting encode options when marshaling cbor.Tag. by @benluddy in #546
- Improve byte string format decoding options by @fxamacker in #550
- Replace
*errors.errorString
withInadmissibleTagContentTypeError
by @fxamacker in #552 - Rename ByteSliceMode to ByteSliceLaterFormatMode, etc by @fxamacker in #554
- Fix panic using SortFastShuffle (unreleased new feaure) to encode a struct with no fields. by @benluddy in #556
🐞 Bug Fixes
- Check well-formedness of data from MarshalCBOR by @fxamacker in #485
- Treat map keys matching the same struct field as duplicates. by @benluddy in #492
- Decouple time.Time parsing from empty interface behavior. by @benluddy in #503
Other changes
Details
- Bump govulncheck from v1.0.1 to v1.0.4 by @fxamacker in #493
- Remove OpenSSF Scorecard until scorecard bug is fixed by @x448 in #495
- Bump github/codeql-action from 3.24.0 to 3.24.5 by @dependabot in #498
- Bump github/codeql-action from 3.24.5 to 3.24.6 by @dependabot in #502
- Enable more linters in .golangci.yml by @fxamacker in #504
- Bump actions/checkout from 4.1.1 to 4.1.2 by @dependabot in #509
- Bump github/codeql-action from 3.24.6 to 3.24.7 by @dependabot in #510
- Bump github/codeql-action from 3.24.7 to 3.24.9 by @dependabot in #511
- Bump github/codeql-action from 3.24.9 to 3.24.10 by @dependabot in #518
- Bump actions/checkout from 4.1.2 to 4.1.3 by @dependabot in #522
- Bump github/codeql-action from 3.24.10 to 3.25.1 by @dependabot in #523
- Bump github/codeql-action from 3.25.1 to 3.25.3 by @dependabot in #529
- Bump actions/checkout from 4.1.3 to 4.1.4 by @dependabot in #530
- Bump actions/setup-go from 4.1.0 to 5.0.1 by @dependabot in #532
- Bump github/codeql-action from 3.25.3 to 3.25.4 by @dependabot in #534
- Bump actions/checkout from 4.1.4 to 4.1.5 by @dependabot in #535
- Bump actions/checkout from 4.1.5 to 4.1.6 by @dependabot in #538
- Bump github/codeql-action from 3.25.4 to 3.25.5 by @dependabot in #539
- Bump golangci-lint from 1.53.3 to 1.54.2 by @fxamacker in #543
- Bump github/codeql-action from 3.25.5 to 3.25.6 by @dependabot in #541
- Bump github/codeql-action from 3.25.6 to 3.25.7 by @dependabot in #547
- Bump golangci-lint to 1.56.2 by @fxamacker in #548
- Bump actions/checkout from 4.1.6 to 4.1.7 by @dependabot in #557
- Bump github/codeql-action from 3.25.7 to 3.25.10 by @dependabot in #559
- Update README.md for v2.7.0 release by @fxamacker in #560
Full Changelog
Full Changelog: v2.6.0...v2.7.0
v2.7.0-rc.0
What's Changed Since v2.6.0
v2.7.0 adds features and improvements that help large projects (e.g. Kubernetes) use CBOR as an alternative to JSON and Protocol Buffers. Other improvements include speedups, improved memory use, bug fixes, decoding/encoding options, etc.
Special thanks to @benluddy for contributing features, optimizations, improvements, bug fixes, and discussions! 👍
⭐ Features and Optimizations
- Add decoding option TimeTagToAny to produce RFC3339 when decoding time into interface{} by @ssuriyan7 in #506
- Bypass sorting overhead for single-entry maps. by @benluddy in #516
- Add decode option to allow rejecting inputs that contain certain simple values. by @benluddy in #481
- Allow rejection of NaN and Inf float values on encode and decode. by @benluddy in #513
- Add SortMode to encode struct fields in a less predictable order. by @benluddy in #515
- Add a decoding option to allow decoding byte string into time.Time. by @benluddy in #524
- Encode structs directly to output buffer. by @benluddy in #519
- Support automatic conversion between text and binary string representations by @benluddy in #476
- Add a method for marshaling directly into a user-provided buffer. by @benluddy in #521
- Add options to disable BinaryMarshaler/BinaryUnmarshaler support. by @benluddy in #526
- Add option to reject decoding bignum tags and encoding big.Int. by @benluddy in #527
- Improve speed & memory use for Diagnose() and DiagnoseFirst() by @benluddy in #533
- Refactor sorted map encode to use fewer buffers for nested maps. by @benluddy in #537
- Allow user to specify buffer by adding
cbor.MarshalToBuffer()
,UserBufferEncMode
interface, etc. by @fxamacker in #553
🛠 Improvements
Improvements focused on fixing or updating new features. For bug fixes to features that were already released, see 🐞 Bug Fixes.
- Refactor to reuse functions and improve code coverage by @fxamacker in #531
- Fix invalid RFC 3339 in TimeTagToAny (unreleased new feature) by @benluddy in #540
- Refactor and improve code by @fxamacker in #542
- Use "cbor:" prefixed error msg when decoding with non-default TimeTagToAnyMode setting by @fxamacker in #544
- Disable conflicting encode options when marshaling cbor.Tag. by @benluddy in #546
- Improve byte string format decoding options by @fxamacker in #550
- Replace
*errors.errorString
withInadmissibleTagContentTypeError
by @fxamacker in #552 - Rename ByteSliceMode to ByteSliceLaterFormatMode, etc by @fxamacker in #554
- Fix panic using SortFastShuffle (unreleased new feaure) to encode a struct with no fields. by @benluddy in #556
🐞 Bug Fixes
- Check well-formedness of data from MarshalCBOR by @fxamacker in #485
- Treat map keys matching the same struct field as duplicates. by @benluddy in #492
- Decouple time.Time parsing from empty interface behavior. by @benluddy in #503
Other changes
Details
- Bump govulncheck from v1.0.1 to v1.0.4 by @fxamacker in #493
- Remove OpenSSF Scorecard until scorecard bug is fixed by @x448 in #495
- Bump github/codeql-action from 3.24.0 to 3.24.5 by @dependabot in #498
- Bump github/codeql-action from 3.24.5 to 3.24.6 by @dependabot in #502
- Enable more linters in .golangci.yml by @fxamacker in #504
- Bump actions/checkout from 4.1.1 to 4.1.2 by @dependabot in #509
- Bump github/codeql-action from 3.24.6 to 3.24.7 by @dependabot in #510
- Bump github/codeql-action from 3.24.7 to 3.24.9 by @dependabot in #511
- Bump github/codeql-action from 3.24.9 to 3.24.10 by @dependabot in #518
- Bump actions/checkout from 4.1.2 to 4.1.3 by @dependabot in #522
- Bump github/codeql-action from 3.24.10 to 3.25.1 by @dependabot in #523
- Bump github/codeql-action from 3.25.1 to 3.25.3 by @dependabot in #529
- Bump actions/checkout from 4.1.3 to 4.1.4 by @dependabot in #530
- Bump actions/setup-go from 4.1.0 to 5.0.1 by @dependabot in #532
- Bump github/codeql-action from 3.25.3 to 3.25.4 by @dependabot in #534
- Bump actions/checkout from 4.1.4 to 4.1.5 by @dependabot in #535
- Bump actions/checkout from 4.1.5 to 4.1.6 by @dependabot in #538
- Bump github/codeql-action from 3.25.4 to 3.25.5 by @dependabot in #539
- Bump golangci-lint from 1.53.3 to 1.54.2 by @fxamacker in #543
- Bump github/codeql-action from 3.25.5 to 3.25.6 by @dependabot in #541
- Bump github/codeql-action from 3.25.6 to 3.25.7 by @dependabot in #547
- Bump golangci-lint to 1.56.2 by @fxamacker in #548
- Bump actions/checkout from 4.1.6 to 4.1.7 by @dependabot in #557
- Bump github/codeql-action from 3.25.7 to 3.25.10 by @dependabot in #559
Full Changelog
Full Changelog: v2.6.0...v2.7.0-rc.0
v2.7.0-beta
What's Changed
Latest changes (among many) include cbor.MarshalToBuffer()
and UserBufferEncMode
interface to support user specified buffer (alternative to built-in buffer pool). This was going to be a release candidate but recent improvements (June 9, 2024) needs fuzzing, etc.
Special thanks to @benluddy for contributing features, optimizations, improvements, bug fixes, and discussions! 👍
⭐ Features and Optimizations
- Add decoding option TimeTagToAny to produce RFC3339 when decoding time into interface{} by @ssuriyan7 in #506
- Bypass sorting overhead for single-entry maps. by @benluddy in #516
- Add decode option to allow rejecting inputs that contain certain simple values. by @benluddy in #481
- Allow rejection of NaN and Inf float values on encode and decode. by @benluddy in #513
- Add SortMode to encode struct fields in a less predictable order. by @benluddy in #515
- Add a decoding option to allow decoding byte string into time.Time. by @benluddy in #524
- Encode structs directly to output buffer. by @benluddy in #519
- Support automatic conversion between text and binary string representations by @benluddy in #476
- Add a method for marshaling directly into a user-provided buffer. by @benluddy in #521
- Add options to disable BinaryMarshaler/BinaryUnmarshaler support. by @benluddy in #526
- Add option to reject decoding bignum tags and encoding big.Int. by @benluddy in #527
- Improve speed & memory use for Diagnose() and DiagnoseFirst() by @benluddy in #533
- Refactor sorted map encode to use fewer buffers for nested maps. by @benluddy in #537
- Allow user to specify buffer by adding
cbor.MarshalToBuffer()
,UserBufferEncMode
interface, etc. by @fxamacker in #553
🛠 Improvements
Improvements focused on fixing or updating new features. For bug fixes to features that were already released, see 🐞 Bug Fixes.
- Refactor to reuse functions and improve code coverage by @fxamacker in #531
- Fix invalid RFC 3339 in TimeTagToAny (unreleased new feature) by @benluddy in #540
- Refactor and improve code by @fxamacker in #542
- Use "cbor:" prefixed error msg when decoding with non-default TimeTagToAnyMode setting by @fxamacker in #544
- Disable conflicting encode options when marshaling cbor.Tag. by @benluddy in #546
- Improve byte string format decoding options by @fxamacker in #550
- Replace
*errors.errorString
withInadmissibleTagContentTypeError
by @fxamacker in #552 - Rename ByteSliceMode to ByteSliceLaterFormatMode, etc by @fxamacker in #554
🐞 Bug Fixes
- Check well-formedness of data from MarshalCBOR by @fxamacker in #485
- Treat map keys matching the same struct field as duplicates. by @benluddy in #492
- Decouple time.Time parsing from empty interface behavior. by @benluddy in #503
Other changes
Details
- Bump govulncheck from v1.0.1 to v1.0.4 by @fxamacker in #493
- Remove OpenSSF Scorecard until scorecard bug is fixed by @x448 in #495
- Bump github/codeql-action from 3.24.0 to 3.24.5 by @dependabot in #498
- Bump github/codeql-action from 3.24.5 to 3.24.6 by @dependabot in #502
- Enable more linters in .golangci.yml by @fxamacker in #504
- Bump actions/checkout from 4.1.1 to 4.1.2 by @dependabot in #509
- Bump github/codeql-action from 3.24.6 to 3.24.7 by @dependabot in #510
- Bump github/codeql-action from 3.24.7 to 3.24.9 by @dependabot in #511
- Bump github/codeql-action from 3.24.9 to 3.24.10 by @dependabot in #518
- Bump actions/checkout from 4.1.2 to 4.1.3 by @dependabot in #522
- Bump github/codeql-action from 3.24.10 to 3.25.1 by @dependabot in #523
- Bump github/codeql-action from 3.25.1 to 3.25.3 by @dependabot in #529
- Bump actions/checkout from 4.1.3 to 4.1.4 by @dependabot in #530
- Bump actions/setup-go from 4.1.0 to 5.0.1 by @dependabot in #532
- Bump github/codeql-action from 3.25.3 to 3.25.4 by @dependabot in #534
- Bump actions/checkout from 4.1.4 to 4.1.5 by @dependabot in #535
- Bump actions/checkout from 4.1.5 to 4.1.6 by @dependabot in #538
- Bump github/codeql-action from 3.25.4 to 3.25.5 by @dependabot in #539
- Bump golangci-lint from 1.53.3 to 1.54.2 by @fxamacker in #543
- Bump github/codeql-action from 3.25.5 to 3.25.6 by @dependabot in #541
- Bump github/codeql-action from 3.25.6 to 3.25.7 by @dependabot in #547
- Bump golangci-lint to 1.56.2 by @fxamacker in #548
Full Changelog
Full Changelog: v2.6.0...v2.7.0-beta
v2.6.0
This release adds important new features, optimizations, bug fixes, and 3 new contributors. Fuzz tests passed 5+ billion execs for CBOR encoding and decoding functions. Minimum officially supported Go is bumped to Go 1.17.
⭐ Features and Optimizations
- Add FieldNameMatching decode option. by @benluddy in #433
- Add option to decode CBOR bignum to
interface{}
as*big.Int
by @fxamacker in #456 - Add 2 more options for decoding CBOR integers to
interface{}
by @fxamacker in #457 - Add encoding option to specify how omitempty fields are encoded by @dinhxuanvu in #453
- New options for encoding Go strings to and from CBOR byte strings by @benluddy in #465
- Add options to support byte string map keys as struct field names by @benluddy in #472
- Add option to specify how to decode unrecognized CBOR tag to
any
by @ssuriyan7 in #475
🚀 Notable Optimizations
-
Improve memory allocs 🗜️ and speed 🚀 of encoding maps by using Go 1.18-1.20 features by @dinhxuanvu in #468
NOTE: Go 1.17 is the minimum version supported by v2.6.0. Go 1.20+ will use optimizations introduced by PR 468.
🛠 Improvements
- Refactor valid() to reject negative values for integer modes by @fxamacker in #434
- Refactor tests to improve consistency and readability by @fxamacker in #458
- Add another test and fix lint errors by @fxamacker in #466
- Refactor map encoding to prep for Go version bump by @fxamacker in #473
- Add
UnrecognizedTagToAny
option toTestDecOptions
by @fxamacker in #484 - Update go.mod to require go 1.17 by @fxamacker in #489
🐞 Bug Fixes
- Fix panic when decoding CBOR nil to
*cbor.SimpleValue
by @fxamacker in #461 - Fix cbor.SimpleValue encoding and decoding by @fxamacker in #464
- Fix EncOption/DecOption unset fields on mode regurgitation. by @benluddy in #480
📖 Docs and CI
- Update README for error handling of CBOR extraneous data by @fxamacker in #426
- Update README for changes in cbor v2.5.0 by @fxamacker in #427
- Update CI and README by @fxamacker in #430
- Update README to add FIDO Alliance, Let's Encrypt, Matrix.org by @fxamacker in #431
- Pin actions/checkout and actions/setup-go by @x448 in #436
- Enable more linters by @fxamacker in #437
- Bump github/codeql-action from 2.22.5 to 2.22.8 by @dependabot in #443
- Document behavior of Unmarshal of unrecognized tags into interface{} by @benluddy in #448
- Bump github/codeql-action from 2.22.8 to 3.22.12 by @dependabot in #455
- Bump github/codeql-action from 3.22.12 to 3.23.0 by @dependabot in #469
New Contributors
- @benluddy made their first contribution in #433
- @dinhxuanvu made their first contribution in #453
- @ssuriyan7 made their first contribution in #475
Full Changelog: v2.5.0...v2.6.0
v2.6.0-rc.0
⭐ Features and Optimizations
- Add FieldNameMatching decode option. by @benluddy in #433
- Add option to decode CBOR bignum to
interface{}
as*big.Int
by @fxamacker in #456 - Add 2 more options for decoding CBOR integers to
interface{}
by @fxamacker in #457 - Add encoding option to specify how omitempty fields are encoded by @dinhxuanvu in #453
- New options for encoding Go strings to and from CBOR byte strings by @benluddy in #465
- Add options to support byte string map keys as struct field names by @benluddy in #472
- Add option to specify how to decode unrecognized CBOR tag to
any
by @ssuriyan7 in #475
🚀 Notable Optimizations
-
Improve memory allocs 🗜️ and speed 🚀 of encoding maps by using Go 1.18-1.20 features by @dinhxuanvu in #468
NOTE: Go 1.17 is the minimum version supported by v2.6.0. Go 1.20+ will use optimizations introduced by PR 468.
🛠 Improvements
- Refactor valid() to reject negative values for integer modes by @fxamacker in #434
- Refactor tests to improve consistency and readability by @fxamacker in #458
- Add another test and fix lint errors by @fxamacker in #466
- Refactor map encoding to prep for Go version bump by @fxamacker in #473
- Add
UnrecognizedTagToAny
option toTestDecOptions
by @fxamacker in #484 - Update go.mod to require go 1.17 by @fxamacker in #489
🐞 Bug Fixes
- Fix panic when decoding CBOR nil to
*cbor.SimpleValue
by @fxamacker in #461 - Fix cbor.SimpleValue encoding and decoding by @fxamacker in #464
- Fix EncOption/DecOption unset fields on mode regurgitation. by @benluddy in #480
📖 Docs and CI
- Update README for error handling of CBOR extraneous data by @fxamacker in #426
- Update README for changes in cbor v2.5.0 by @fxamacker in #427
- Update CI and README by @fxamacker in #430
- Update README to add FIDO Alliance, Let's Encrypt, Matrix.org by @fxamacker in #431
- Pin actions/checkout and actions/setup-go by @x448 in #436
- Enable more linters by @fxamacker in #437
- Bump github/codeql-action from 2.22.5 to 2.22.8 by @dependabot in #443
- Document behavior of Unmarshal of unrecognized tags into interface{} by @benluddy in #448
- Bump github/codeql-action from 2.22.8 to 3.22.12 by @dependabot in #455
- Bump github/codeql-action from 3.22.12 to 3.23.0 by @dependabot in #469
New Contributors
- @benluddy made their first contribution in #433
- @dinhxuanvu made their first contribution in #453
- @ssuriyan7 made their first contribution in #475
Full Changelog: v2.5.0...v2.6.0-rc.0
v2.5.0
This release adds important new features, optimizations, bug fixes, and 8 new contributors. Fuzz tests passed 5+ billion execs for CBOR encoding and decoding functions.
Notable changes are split into 3 categories.
⭐ Notable Changes to Review Before Upgrading
These new features and bug fixes were cherry-picked to highlight for review (for projects using older version).
- PR 370: Add
SimpleValue
type to more fully support CBOR Simple Values, including values not assigned by IANA and... - PR 376: Add
ByteString
type to support CBOR maps with byte string keys because Go doesn't allow []byte as map keys and... - PR 379: Make
Decoder.Decode()
returnio.ErrUnexpectedEOF
instead ofio.EOF
on EOF if current CBOR data item is incomplete. - PR 380: Make
Unmarshal()
andValid()
returncbor.ExtraneousDataError
(instead of ignoring extraneous data if any remain). - PR 387: Retry in Decoder if io.Reader's Read() returns 0 bytes read with nil error. Add tests to get 100% code coverage for stream.go.
⭐ More Notable Changes
- PR 342: Add
DecOptions.UTF8
to decode invalid UTF-8. Default is unchanged (reject invalid UTF-8 and return error). - PR 355 Allow
MaxNestedLevels
setting to be configured up to 65535. - PR 352, 377: Add
EncOptions.NilContainersMode
to encode nil Go maps and slices as either CBOR nil (default) or empty container. - PR 381: Add
Decoder.Skip()
to skip CBOR data item in CBOR Sequences (RFC 8742). - PR 386 Add functions for Extended Diagnostic Notation (RFC 8610 Appendix G).
- PR 398 Add
UnmarshalFirst()
to decode CBOR data item and also return remaining bytes. - PR 400 Deprecate
Valid
and addWellformed
to replace it. - PR 402 Add
UnmarshalFirst()
toDecMode
interface. - PR 412 Add
Decoder.Buffered
to return remaining data in buffer.
🚀 Notable Changes Affecting Speed or Memory Use
- PR 335: Reuse underlying array if
RawMessage
has sufficient capacity. - PR 382: Return buffer to pool in
Encode()
. It adds a bit of overhead toEncode()
butNewEncoder().Encode()
is faster and uses less memory.
Benchmark comparison for PR 382 shows significant improvement in speed and memory use.
🚀 (click to expand) 🚀
Benchmarks provided by @x448 for NewEncoder().Encode()
optimized in PR 382.
$ benchstat bench-v2.4.0.log bench-f9e6291.log
goos: linux
goarch: amd64
pkg: github.com/fxamacker/cbor/v2
cpu: 12th Gen Intel(R) Core(TM) i7-12700H
│ bench-v2.4.0.log │ bench-f9e6291.log │
│ sec/op │ sec/op vs base │
NewEncoderEncode/Go_bool_to_CBOR_bool-20 236.70n ± 2% 58.04n ± 1% -75.48% (p=0.000 n=10)
NewEncoderEncode/Go_uint64_to_CBOR_positive_int-20 238.00n ± 2% 63.93n ± 1% -73.14% (p=0.000 n=10)
NewEncoderEncode/Go_int64_to_CBOR_negative_int-20 238.65n ± 2% 64.88n ± 1% -72.81% (p=0.000 n=10)
NewEncoderEncode/Go_float64_to_CBOR_float-20 242.00n ± 2% 63.00n ± 1% -73.97% (p=0.000 n=10)
NewEncoderEncode/Go_[]uint8_to_CBOR_bytes-20 245.60n ± 1% 68.55n ± 1% -72.09% (p=0.000 n=10)
NewEncoderEncode/Go_string_to_CBOR_text-20 243.20n ± 3% 68.39n ± 1% -71.88% (p=0.000 n=10)
NewEncoderEncode/Go_[]int_to_CBOR_array-20 563.0n ± 2% 378.3n ± 0% -32.81% (p=0.000 n=10)
NewEncoderEncode/Go_map[string]string_to_CBOR_map-20 2.043µ ± 2% 1.906µ ± 2% -6.75% (p=0.000 n=10)
geomean 349.7n 122.7n -64.92%
│ bench-v2.4.0.log │ bench-f9e6291.log │
│ B/op │ B/op vs base │
NewEncoderEncode/Go_bool_to_CBOR_bool-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_uint64_to_CBOR_positive_int-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_int64_to_CBOR_negative_int-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_float64_to_CBOR_float-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_[]uint8_to_CBOR_bytes-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_string_to_CBOR_text-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_[]int_to_CBOR_array-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_map[string]string_to_CBOR_map-20 544.0 ± 0% 416.0 ± 0% -23.53% (p=0.000 n=10)
geomean 153.4 ? ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean
│ bench-v2.4.0.log │ bench-f9e6291.log │
│ allocs/op │ allocs/op vs base │
NewEncoderEncode/Go_bool_to_CBOR_bool-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_uint64_to_CBOR_positive_int-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_int64_to_CBOR_negative_int-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_float64_to_CBOR_float-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_[]uint8_to_CBOR_bytes-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_string_to_CBOR_text-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_[]int_to_CBOR_array-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_map[string]string_to_CBOR_map-20 28.00 ± 0% 26.00 ± 0% -7.14% (p=0.000 n=10)
geomean 2.782 ? ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean
What's Changed
All merged pull requests are listed here (including the already highlighted ones).
(click to expand)
Changes to Code
Most coding changes here were already mentioned.
- Reuse underlying array if RawMessage has sufficient capacity by @zensh in #335
- Add decoding option to allow invalid UTF-8 by @fxamacker in #342
- Allow MaxNestedLevels to be up to 65535 by @immesys in #355
- Add support for unassigned/reserved CBOR simple values by @fxamacker in #370
- Add ByteString type to support any CBOR byte string by @fxamacker in #376
- add option to enforce nil container marshaling as empty containers by @dedefer in #352
- Refactor NilContainersMode option by @fxamacker in #377
- Make Decoder.Decode() return io.UnexpectedEOF instead of io.EOF if CBOR data item is truncated by @fxamacker in #379
- Fix handling of extra data in Unmarshal() & Valid() by @fxamacker in #380
- Add Decoder.Skip() to skip CBOR data item in CBOR Sequences (RFC 8742) by @fxamacker in #381
- Return buffer to pool when using Encoder by @fxamacker in #382
- Retry in decoder if Read() returns 0 bytes read with nil error by @fxamacker in #387
- Deprecate Valid() and add Wellformed() to replace it by @fxamacker in #400
- Add UnmarshalFirst by @immesys in #398
- Add UnmarshalFirst to DecMode interface by @fxamacker in #402
- Add functions for Extended Diagnostic Notation (RFC 8610 Appendix G) by @zensh in #386
- Add more tests for Diagnose and DiagnoseFirst by @fxamacker in #405
- Fix Diagnose to return io.EOF error on empty data by @fxamacker in #410
- Add
Decoder.Buffered
to return buffered data by @fxamacker in #412 - Fix
Diagnose()
to returnio.EOF
error on empty data by @fxamacker in #410
Changes to CI, Comments, and Docs
- Remove trailing whitespaces in .golangci.yml by @CodingVoid in #333
- Update ci.yml by @fxamacker in #334
- Update ci.yml by ...
v2.5.0-beta5
v2.5.0-beta5 is fuzz tested and production quality, but docs need to be updated before releasing v2.5.0.
IMPORTANT: Please view these release notes (esp. v2.5.0-beta) before upgrading from v2.4 or earlier:
- v2.5.0-beta4 - Bugfix for
Diagnose
to returnio.EOF
on empty data. - v2.5.0-beta3 - Add functions:
Diagnose
,DiagnoseFirst
,UnmarshalFirst
,Wellformed
. - v2.5.0-beta2 - Bugfix to retry in
Decoder
ifio.Reader
'sRead()
returns 0 bytes read with nil error. - v2.5.0-beta - Notable improvements, optimizations, bugfixes, and 8 new contributors!
What's Changed since v2.5.0-beta4
- Add
Decoder.Buffered
to return remaining data in buffer by @fxamacker in #412 - Update README.md for v2.5.0-beta5 by @fxamacker in #413
Full Changelog: v2.5.0-beta4...v2.5.0-beta5
v2.5.0-beta4
Features already present in v2.4 are release quality. Newly added functions require more fuzzing and docs.
IMPORTANT: Please view these release notes (esp. v2.5.0-beta) before upgrading from v2.4:
- v2.5.0-beta3 - Add
Diagnose()
,DiagnoseFirst()
,UnmarshalFirst()
,Wellformed()
. - v2.5.0-beta2 - Bugfix and release notes include benchmark comparison of v2.5.0-beta2 vs v2.4.0.
- v2.5.0-beta - Notable improvements, optimizations, bugfixes, and 8 new contributors!
What's Changed Since v2.5.0-beta3
- Bump safer-golangci-lint to 1.52.2 by @x448 in #408
- Fix
Diagnose()
to returnio.EOF
error on empty data by @fxamacker in #410 - Update README.md for cbor v2.5.0-beta4 by @fxamacker in #411
Full Changelog: v2.5.0-beta3...v2.5.0-beta4
v2.5.0-beta3
This release adds 4 new functions: UnmarshalFirst
, Diagnose
, DiagnoseFirst
, and Wellformed
. In addition Valid
function is deprecated (use Wellformed
instead).
UnmarshalFirst
decodes first CBOR data item and returns remaining bytes. This is useful for CBOR Sequences (RFC 8742) and also becauseUnmarshal
was fixed in v2.5.0-beta to returnExtraneousDataError
if there are remaining bytes.Diagnose
andDiagnoseFirst
returns human-readable Extended Diagnostic Notation (RFC 8610 Appendix G) for the given CBOR encoding. These are useful for debugging and allows more user-friendly error logging.
What's Changed (since v2.5.0-beta2)
- Deprecate Valid() and add Wellformed() to replace it by @fxamacker in #400
- Add UnmarshalFirst by @immesys in #398
- Add UnmarshalFirst to DecMode interface by @fxamacker in #402
- Add functions for Extended Diagnostic Notation (RFC 8610 Appendix G) by @zensh in #386
- Add more tests for Diagnose and DiagnoseFirst by @fxamacker in #405
Changes to CI and Documentation
- Create govulncheck.yml by @fxamacker in #393
- Update README for cbor v2.5.0-beta2 by @fxamacker in #394
- Bump actions/setup-go from 3 to 4 by @dependabot in #395
- Update ci-go-cover.yml by @x448 in #404
- Update README for CBOR Sequences RFC 8742 by @fxamacker in #406
- Update README.md for v2.5.0-beta3 by @fxamacker in #407
Special Thanks
Thank you @immesys, @zensh, and @x448 for your contributions!
Full Changelog: v2.5.0-beta2...v2.5.0-beta3
v2.5.0-beta2
There are fewer changes in v2.5.0-beta2 compared to v2.5.0-beta. Speed and memory improvements since v2.4.0 are from v2.5.0-beta. Tests cover 98.5% and reached 100% coverage for stream.go (e.g. Decoder using the provided io.Reader).
What's Changed Since v2.5.0-beta
- Retry in Decoder if io.Reader's Read() returns 0 bytes read with nil error by @fxamacker in #387
- This PR also added more tests so we have 100% coverage for stream.go.
- Update fxamacker_cbor_banner.png for v2.5 by @x448 in #383
- bump safer-golangci-lint.yml to 1.51.1 by @x448 in #389
Go language recommends that Read
implementations for io.Reader avoid returning 0 with nil error. It also recommends that callers receiving 0 and nil from Read
should treat it as if nothing happened. This edge case is handled properly now.
@x448 shared benchmarks comparison of v2.4.0 vs v2.5.0-beta2. Performance improvements are from v2.5.0-beta.
Comparison of v2.5.0-beta2 vs v2.4.0
$ benchstat benchNewEncoderEncode-v2.4.0.log benchNewEncoderEncode-f9e6291.log
goos: linux
goarch: amd64
pkg: github.com/fxamacker/cbor/v2
cpu: 12th Gen Intel(R) Core(TM) i7-12700H
│ benchNewEncoderEncode-v2.4.0.log │ benchNewEncoderEncode-f9e6291.log │
│ sec/op │ sec/op vs base │
NewEncoderEncode/Go_bool_to_CBOR_bool-20 236.70n ± 2% 58.04n ± 1% -75.48% (p=0.000 n=10)
NewEncoderEncode/Go_uint64_to_CBOR_positive_int-20 238.00n ± 2% 63.93n ± 1% -73.14% (p=0.000 n=10)
NewEncoderEncode/Go_int64_to_CBOR_negative_int-20 238.65n ± 2% 64.88n ± 1% -72.81% (p=0.000 n=10)
NewEncoderEncode/Go_float64_to_CBOR_float-20 242.00n ± 2% 63.00n ± 1% -73.97% (p=0.000 n=10)
NewEncoderEncode/Go_[]uint8_to_CBOR_bytes-20 245.60n ± 1% 68.55n ± 1% -72.09% (p=0.000 n=10)
NewEncoderEncode/Go_string_to_CBOR_text-20 243.20n ± 3% 68.39n ± 1% -71.88% (p=0.000 n=10)
NewEncoderEncode/Go_[]int_to_CBOR_array-20 563.0n ± 2% 378.3n ± 0% -32.81% (p=0.000 n=10)
NewEncoderEncode/Go_map[string]string_to_CBOR_map-20 2.043µ ± 2% 1.906µ ± 2% -6.75% (p=0.000 n=10)
geomean 349.7n 122.7n -64.92%
│ benchNewEncoderEncode-v2.4.0.log │ benchNewEncoderEncode-f9e6291.log │
│ B/op │ B/op vs base │
NewEncoderEncode/Go_bool_to_CBOR_bool-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_uint64_to_CBOR_positive_int-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_int64_to_CBOR_negative_int-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_float64_to_CBOR_float-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_[]uint8_to_CBOR_bytes-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_string_to_CBOR_text-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_[]int_to_CBOR_array-20 128.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_map[string]string_to_CBOR_map-20 544.0 ± 0% 416.0 ± 0% -23.53% (p=0.000 n=10)
geomean 153.4 ? ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean
│ benchNewEncoderEncode-v2.4.0.log │ benchNewEncoderEncode-f9e6291.log │
│ allocs/op │ allocs/op vs base │
NewEncoderEncode/Go_bool_to_CBOR_bool-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_uint64_to_CBOR_positive_int-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_int64_to_CBOR_negative_int-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_float64_to_CBOR_float-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_[]uint8_to_CBOR_bytes-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_string_to_CBOR_text-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_[]int_to_CBOR_array-20 2.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NewEncoderEncode/Go_map[string]string_to_CBOR_map-20 28.00 ± 0% 26.00 ± 0% -7.14% (p=0.000 n=10)
geomean 2.782 ? ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean
Full Changelog: v2.5.0-beta...v2.5.0-beta2