This release is larger than usual because it has been a year since last release. It adds new features, bug fixes, and 8 new contributors.
All unit tests pass (98.4% coverage). Fuzz tests passed hundreds of millions of execs. Fuzzing will continue until v2.5.0 is tagged.
Notable Changes to Review Before Upgrading
These new features and bug fixes were cherry-picked to highlight for review (for projects using older version in production).
-
PR 370: Add
SimpleValuetype to more fully support CBOR Simple Values, including values not assigned by IANA and... -
PR 376: Add
ByteStringtype to support CBOR maps with byte string keys because Go doesn't allow []byte as map keys and... -
PR 379: Make
Decoder.Decode()returnio.ErrUnexpectedEOFinstead ofio.EOFon EOF if current CBOR data item is incomplete. -
PR 380: Make
Unmarshal()andValid()returncbor.ExtraneousDataError(instead of ignoring extraneous data if any remain).
Notable Changes Affecting Speed or Memory Use
-
PR 335: Reuse underlying array if
RawMessagehas sufficient capacity. -
PR 382: Return buffer to pool in
Encode(). It adds a bit of overhead toEncode()butNewEncoder().Encode()is a lot faster and uses less memory.
Other Notable Changes:
-
PR 342: Add
DecOptions.UTF8to 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.NilContainersModeto 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).
What's Changed
Most coding changes are already mentioned. Other changes include CI, comments, and docs.
(click to expand)
All Changes to Code
- Add support for unassigned/reserved CBOR simple values by @fxamacker in https://github.com/fxamacker/cbor/pull/370
- Add ByteString type to support any CBOR byte string by @fxamacker and @agaffney in https://github.com/fxamacker/cbor/pull/376
- Make Decoder.Decode() return io.ErrUnexpectedEOF instead of io.EOF on EOF if CBOR data item is truncated by @fxamacker in https://github.com/fxamacker/cbor/pull/379
- Fix handling of extra data in Unmarshal() & Valid() by @fxamacker in https://github.com/fxamacker/cbor/pull/380
- Add Decoder.Skip() to skip CBOR data item in CBOR Sequences (RFC 8742) by @fxamacker in https://github.com/fxamacker/cbor/pull/381
- Reuse underlying array if RawMessage has sufficient capacity by @zensh in https://github.com/fxamacker/cbor/pull/335
- Return buffer to pool when using Encoder.Encode by @fxamacker in https://github.com/fxamacker/cbor/pull/382
- Add decoding option to allow invalid UTF-8 by @fxamacker in https://github.com/fxamacker/cbor/pull/342
- Allow MaxNestedLevels to be up to 65535 by @immesys in https://github.com/fxamacker/cbor/pull/355
- add option to enforce nil container marshaling as empty containers by @dedefer in https://github.com/fxamacker/cbor/pull/352
- Refactor NilContainersMode option by @fxamacker in https://github.com/fxamacker/cbor/pull/377
Changes to CI, Comments, and Docs
-
Remove trailing whitespaces in .golangci.yml by @CodingVoid in https://github.com/fxamacker/cbor/pull/333
-
Update ci.yml by @fxamacker in https://github.com/fxamacker/cbor/pull/334
-
Update ci.yml by @x448 in https://github.com/fxamacker/cbor/pull/339
-
Update ci.yml by @x448 in https://github.com/fxamacker/cbor/pull/340
-
Remove default permissions from GitHub Actions workflows by @x448 in https://github.com/fxamacker/cbor/pull/341
-
Fix ci for stream mode branch by @fxamacker in https://github.com/fxamacker/cbor/pull/344
-
Create dependabot.yml by @x448 in https://github.com/fxamacker/cbor/pull/346
-
Bump github/codeql-action from 1 to 2 by @dependabot in https://github.com/fxamacker/cbor/pull/347
-
Update pull_request_template.md by @x448 in https://github.com/fxamacker/cbor/pull/350
-
Fix typos by @deeglaze in https://github.com/fxamacker/cbor/pull/353
-
Mention security assessment by NCC Group by @fxamacker in https://github.com/fxamacker/cbor/pull/358
-
godoc.org link in Readme should point to v2 by @jdharms in https://github.com/fxamacker/cbor/pull/361
-
Add Go 1.19 to ci.yml test matrix by @fxamacker in https://github.com/fxamacker/cbor/pull/363
-
Bump safer-golangci-lint.yml to 1.46.2 by @x448 in https://github.com/fxamacker/cbor/pull/365
-
Bump Go to 1.19 in ci-go-cover.yml by @x448 in https://github.com/fxamacker/cbor/pull/367
-
Bump safer-golangci-lint.yml to 1.49.0.1 by @x448 in https://github.com/fxamacker/cbor/pull/368
-
Mention 1276 repos depend on fxamacker/cbor/v2 by @x448 in https://github.com/fxamacker/cbor/pull/371
-
Fix EncMode example in the package comment by @creachadair in https://github.com/fxamacker/cbor/pull/375
New Contributors (alphabetically)
- @agaffney made their first contribution in https://github.com/fxamacker/cbor/pull/376
- @CodingVoid made their first contribution in https://github.com/fxamacker/cbor/pull/333
- @creachadair made their first contribution in https://github.com/fxamacker/cbor/pull/375
- @dedefer made their first contribution in https://github.com/fxamacker/cbor/pull/352
- @deeglaze made their first contribution in https://github.com/fxamacker/cbor/pull/353
- @immesys made their first contribution in https://github.com/fxamacker/cbor/pull/355
- @jdharms made their first contribution in https://github.com/fxamacker/cbor/pull/361
- @zensh made their first contribution in https://github.com/fxamacker/cbor/pull/335
Non-coding contibutions were made by opening notable issues that directly or indirectly improved this release.
- @burdiyan opened issue and followups that led to
Encode()returning buffer to pool as default behavior. - @espoal opened issue and followups that led to adding Skip() feature for CBOR Sequences (RFC 8742).
- @qmuntal opened issue and @x448 added feedback that led to improved support for CBOR Simple Values.
- @x448 opened multiple issues and provided helpful feedback in addition to his merged PR.
- @zensh opened multiple issues and provided helpful feedback in addition to his merged PR.
Full Changelog: https://github.com/fxamacker/cbor/compare/v2.4.0...v2.5.0-beta