Thomas Pelletier
9dd7f1af78
encoder: add back the commented option ( #893 )
2023-08-28 14:29:26 -04:00
Mikhail f. Shiryaev
4a5c27c299
decode: fix wrong indention for tables' comments ( #892 )
2023-08-28 13:23:11 -04:00
Thomas Pelletier
4040373cfd
Encode: fix ignored indent of array tables ( #889 )
...
Fixes #888
2023-08-28 09:52:11 -04:00
MrJetBOX
8bb1e08dc7
Encode: fix support for arrays ( #876 )
2023-05-29 09:41:33 -04:00
Gordon
d34104d493
Support text Un/Marshaller for map keys ( #863 )
2023-05-09 17:56:57 +02:00
Cuong Manh Le
090cccf4ba
Fix inline table first key value whitespace ( #837 )
...
Co-authored-by: Cuong Manh Le <cuong@windscribe.com >
2023-02-01 12:00:09 +01:00
Thomas Pelletier
2d8433b69e
Encode: don't inherit omitempty ( #803 )
...
Fixes #786 .
2022-08-15 11:29:46 -04:00
Thomas Pelletier
fb6d1d6c2b
Marshal: define and fix newlines behavior when using omitempty ( #798 )
...
Ref #786
2022-07-24 15:40:20 -04:00
Thomas Pelletier
85bfc0ed51
Encode: add bound check for uint64 > math.Int64 ( #785 )
...
As brought up on #782 , there is an asymetry between numbers go-toml can encode
and decode. Specifically, unsigned numbers larger than `math.Int64` could be
encoded but not decoded.
We considered two options: allow decoding of those numbers, or prevent those
numbers to be decoded.
Ultimately we decided to narrow the range of numbers to be encoded. The TOML
specification only requires parsers to support at least the 64 bits integer
range. Allowing larger numbers would create non-standard TOML documents, which
may not be readable (at best) by other implementations. It is a safer default to
generate documents valid by default. People who wish to deal with larger numbers
can provide a custom type implementing `encoding.TextMarshaler`.
Refs #781
2022-05-31 22:10:41 -04:00
Thomas Pelletier
b2e0231cc9
Encode: fix multiline comment ( #775 )
...
Fixes #768
2022-05-10 14:53:26 +02:00
Thomas Pelletier
8bbb673431
Fuzzing setup and fixes ( #755 )
...
* encode: fix localdate formatting
* encode: fix empty key marshaling
* encode: fix invalid quotation of time.Time
* encode: ensure control chars are escaped
* decode: always use UTC for zero tz
* encode: check for invalid characters in keys
* encode: always construct map for empty array tables
* fuzz: add go 1.18 fuzz test
* encode: handle NaNs
* encode: allow new lines in quoted keys
* encode: never emit table inside array
* encode: don't capitalize inf
2022-04-10 21:37:12 -04:00
Thomas Pelletier
2377ac4bc0
encode: fix embedded interfaces ( #753 )
...
Resolve marshaling regression when handling an embedded interface in a
struct.
Fixes #752
2022-04-08 09:25:54 -04:00
Thomas Pelletier
068279f13b
encode: respect stdlib rules for embedded structs ( #747 )
2022-04-07 19:51:09 -04:00
Thomas Pelletier
5fd6e9cce0
Encode: add comment struct tag ( #711 )
...
Similar to v1, add a `comment` struct that that makes the encoder emit a comment
before the annotated element, if permitted. Unlike v1, comments are compact by
default (and cannot be changed).
Fixes #595 .
2021-12-26 18:29:46 +01:00
Thomas Pelletier
0d20a84523
Encoder: omitempty flag ( #692 )
...
Fixes #597
2021-11-30 21:32:28 -05:00
Thomas Pelletier
2b3de620e8
Encoder: try to use pointer type TextMarshaler ( #679 )
...
If a type does not implement the encoding.TextMarshaler interface but
its pointer type does, use it if possible.
Fixes #678
2021-11-24 14:43:49 -05:00
Thomas Pelletier
64fe47161f
API: Encoder and Decoder options are chainable ( #670 )
...
Fixes #583
2021-11-13 19:04:53 -05:00
Sterling Hanenkamp
4984dcb5e9
encode: ensure floats have decimal point ( #615 )
...
Fixes #571
Co-authored-by: Sterling Hanenkamp <sterling@ziprecruiter.com >
2021-10-14 08:34:54 -04:00
Thomas Pelletier
ee9b902222
unmarshal: convert ints if target type is compatible ( #594 )
...
This is required to support custom types.
Fixes #590
2021-09-09 21:25:14 -04:00
kkHAIKE
8be357dfa1
Add LocalTime to interface{} decode support ( #567 )
...
Co-authored-by: Thomas Pelletier <thomas@pelletier.codes >
2021-07-21 17:50:12 +02:00
Thomas Pelletier
250e073408
Stack-based unmarshaler ( #546 )
...
* Benchmark script
* Rewrite unmarshaler using the stack
Instead of tracking the build chain using `target`s, use the stack
instead.
Working and most benchmarks look good, but regression on structs unmarshalling.
~60% slower on ReferenceFile/struct.
* Shortcut to check if last node of iterator
* Remove unecessary pointer allocation
* Skip over unused keys without marking them as seen
* Add some tests
* Fix mktemp on macos
2021-05-31 12:14:13 -04:00
Thomas Pelletier
95c701b253
Increase test coverage ( #538 )
...
Also fix array in map bug.
2021-05-10 20:17:05 -04:00
Thomas Pelletier
45ea20024b
Readme ( #535 )
2021-05-08 17:03:51 -04:00
Vincent Serpoul
201d5dd422
golangci-lint: misc ( #529 )
2021-04-27 20:29:00 -04:00
Thomas Pelletier
931f02a519
encoder: support indentation ( #525 )
2021-04-23 17:08:27 -04:00
Vincent Serpoul
466faaab9f
golangci-lint: marshaler, strict ( #523 )
2021-04-23 10:41:21 -04:00
Thomas Pelletier
21445f5170
Add test for issue #424
2021-04-21 22:27:30 -04:00
Thomas Pelletier
9ba52996d8
Encoder multiline array ( #520 )
2021-04-21 22:13:45 -04:00
Thomas Pelletier
6fe332a869
Encoder inline tables ( #519 )
2021-04-21 19:11:15 -04:00
Vincent Serpoul
dca2103910
golangci-lint: marshaler ( #516 )
2021-04-20 20:24:44 -04:00
Thomas Pelletier
9e122af5fc
encoder: support multiline strings + local options
2021-04-10 17:58:37 -04:00
Thomas Pelletier
e1f035461b
encoder: simplify quoted strings escaping
2021-04-08 22:02:41 -04:00
Thomas Pelletier
37714006b6
V2 Marshaler MVP ( #495 )
2021-04-08 10:07:29 -04:00