Commit Graph

17 Commits

Author SHA1 Message Date
adeinega
6d25d3f82f Fix typos here and there.
Signed-off-by: Andrii Deinega andrii.deinega@gmail.com
2025-06-10 13:31:56 -07:00
Faye Amacker
cbe7442e9e
Update docs for cbor v2.8.0 (#649)
Some checks failed
CodeQL / Analyze (go) (push) Has been cancelled
govulncheck / Check (push) Has been cancelled
Update README.md:
- Update "Status" section.
- Replace "struct tags" with "struct tag options" when referring to options.

Update doc.go:
- Mention omitzero option (for struct tags) in more places. Also mention Diagnose, DiagnoseFirst, UnmarshalFirst, etc. added in prior releases.
- Add example using UnmarshalFirst to show support for trailing bytes (extraneous data) typically found in CBOR Sequences (RFC 8742).
-  Add example using DiagnoseFirst to show support for representing binary CBOR data item in Extended Diagnostic Notation (human-readable text inspired by JSON).
- Replace "struct tags" with "struct tag options" when referring to options.

Update example_test.go
- Replace "struct tags" with "struct tag options" when referring to options.
2025-03-30 13:25:59 -05:00
Faye Amacker
4206c1d5f0 Refactor tests for readability 2023-12-28 20:34:09 -06:00
Faye Amacker
11b0c76f00
Update example_test.go (#210)
Added comment to remove "/v2" suffix when not using Go modules.
2020-04-05 10:37:58 -05:00
Faye Amacker
b2ab983bba
Update README.md for v2.1 (#158)
Some checks failed
cover ≥97% / Coverage (push) Has been cancelled
ci / Test on ${{matrix.os}} (macos-latest) (push) Has been cancelled
ci / Test on ${{matrix.os}} (ubuntu-latest) (push) Has been cancelled
linters / Lint (push) Has been cancelled
* Add CBOR tags example, "Encoding and Decoding CWT (CBOR Web Token) with CBOR Tags".
* v2.1 passed 361+ million execs in coverage-guided fuzzing on Feb 17, 2020.
* Package cbor is a fast & safe CBOR encoder & decoder (RFC 7049) with a 
standard API + toarray & keyasint struct tags, CBOR tags, float64->32->16, 
CTAP2 & Canonical CBOR, duplicate map key options, and is customizable via 
simple API.
2020-02-17 16:49:01 -06:00
Faye Amacker
10f672e577
Update benchmarks and examples (#154) 2020-02-17 00:50:15 -06:00
Faye Amacker
158e5313bc
Add v2.0 API, faster CBOR, fewer allocs
Some checks failed
ci / Test on ${{matrix.os}} (ubuntu-latest) (push) Has been cancelled
cover ≥97% / Coverage (push) Has been cancelled
ci / Test on ${{matrix.os}} (macos-latest) (push) Has been cancelled
linters / Lint (push) Has been cancelled
Implement v2.0 API for easier CBOR encoding/decoding.  See issue #117 for summary.

Replaced EncOptions.TimeRFC3339 bool with TimeMode values:
* TimeUnix                   // secs, converted to smallest CBOR integer that fits
* TimeUnixMicro           // μs, CBOR float with subsecs in fractional part
* TimeUnixDynamic      // secs or μs, either int or float depending on empty subsecs
* TimeRFC3339            // secs, string
* TimeRFC3339Nano    // ns, string with trailing zeros removed

Decode CBOR time NaN and Infinity values to Go's "zero time" value.  
This is how CBOR Null values are decoded to time.Time.

Removed deprecated options (Canonical & CTAP2Canoical) in EncOptions.

Removed Valid() function.

Improved performance and memory alloc by 
* using pointer receivers for types implementing sort.Interface and others.
* storing pointer in sync.Pool.
* storing pointer as map value in sync.Map.

Used roughly 20 linters and resolved many reported issues.

Switched to GitHub Actions for CI to lint, test, and check code coverage.

Extensive improvements to README.md.  

Thanks @x448 for API design ideas, travis & github ci configs, filing issues, 
and improving README.md.

Closes: #107
Closes: #119
Closes: #120
Closes: #123 
Closes: #124 
Closes: #127
2020-02-02 23:24:18 -06:00
Faye Amacker
0bed4727aa Update copyright to only have year in LICENSE file
Each source file doesn't mention year and LICENSE file has "2019 - present".
2020-01-18 16:45:39 -06:00
Faye Amacker
85c6bb3496 Improve error messages in unit tests 2020-01-09 18:58:00 -06:00
Faye Amacker
b7b57334cf Add 3 funcs to create predefined encoding configs
* CanonicalEncOptions() -- Canonical CBOR (RFC 7049)
* CTAP2EncOptions() -- CTAP2 Canonical CBOR
* CoreDetEncOptions() -- Core Deterministic Encoding

The first two are well-known.  Core Deterministic Encoding uses:
* SortBytewiseLexical
* ShortestFloat16

Closes: #42
2020-01-02 13:39:11 -06:00
Faye Amacker
3b78ee02a8 Add EncOptions.Sort option
EncOptions.Canonical is deprecated.
Use `cbor.EncOptions{Sort: cbor.SortCanonical}`.

EncOptions.CTAP2Canonical is deprecated.
Use `cbor.EncOptions{Sort: cbor.SortCTAP2}`.

This commit addresses part of issue #74.
2019-12-20 17:50:38 -06:00
Faye Amacker
71ea0c5ad9 Relax decoding restriction on CBOR int to Go float
This change allows decoding CBOR int to Go float.

Sometimes both integers or floating-point numbers can be used to
represent numbers in CBOR data, such as SenML (RFC 8428).  Examples
use floating point for JSON and XML, while using int for CBOR.

Closes: #41
2019-11-22 18:07:10 -06:00
Faye Amacker
2964577e9a Add toarray and keyasint examples 2019-11-19 22:20:44 -06:00
Faye Amacker
61d7682fd3 Add CWT, COSE, SenML, and WebAuthn examples 2019-11-19 18:49:52 -06:00
Faye Amacker
855cc667cd Add encoding and decoding support for time.Time 2019-09-02 21:56:14 -05:00
Faye Amacker
245666d92e Add examples of encoding indefinite length values 2019-08-30 15:09:42 -05:00
Faye Amacker
0cf6159c0f Add go code, tests, benchmarks, and go module. 2019-05-15 21:32:15 -05:00