Robert Günzler
4e9e0ee19b
Add Encoder/Decoder types ( #192 )
...
Usage is similar to the stdlibs JSON encoder/decoder but I tried to
leave the general structure of the code the same.
Main motivation was to support encoding/decoding options to allow
encoding string-type map keys as quoted TOML keys.
This was implemented on the Encoder with QuoteMapKeys(bool).
> The TOML spec supports using UTF-8 strings as keys.
> https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md#table
2017-10-24 14:10:38 -07:00
Thomas Pelletier
8c31c2ec65
Fix fuzz ( #199 )
...
Fix fuzzer (LoadString does not exist), and mention it in the README.
2017-10-21 19:23:38 -07:00
Thomas Pelletier
6d858869d3
Describe versioning policy in README ( #198 )
2017-10-21 19:08:12 -07:00
Kazuyoshi Kato
1916042ba2
Add fuzz.sh to do fuzzing with go-fuzz ( #194 )
...
Fixes #181
2017-10-21 16:37:53 -07:00
Kazuyoshi Kato
a410399d2c
Support single quoted keys ( #193 )
...
Fixes #61
2017-10-21 23:14:36 +00:00
Kazuyoshi Kato
878c11e70e
Unmarshal should report a type mismatch as an error ( #196 )
...
Fixes #186
2017-10-21 15:29:03 -07:00
Kazuyoshi Kato
19ece5dc77
Fix typos ( #195 )
...
Most of them are caught by Go Report Card.
https://goreportcard.com/report/github.com/pelletier/go-toml
2017-10-21 15:26:06 -07:00
Maxime Le Conte des Floris
d01db88be9
Fix example code in README ( #197 )
2017-10-21 15:24:36 -07:00
Thomas Pelletier
2009e44b6f
Improve doc for un/marshal functions ( #189 )
2017-10-01 15:47:47 -07:00
Yvonnick Esnault
690dbc9ee7
Comment annotation for Marshal ( #185 )
2017-10-01 15:05:24 -07:00
KANEKO Tatsuya
16398bac15
Fix example code in README ( #187 )
v1.0.1
2017-09-24 11:42:18 -07:00
Edward Betts
1d6b12b7cb
Correct query/parser spelling mistake ( #182 )
2017-09-04 12:58:09 -07:00
Thomas Pelletier
9c1b4e331f
Bump golang to 1.9 ( #179 )
2017-08-24 20:46:50 -07:00
178inaba
4692b8f9ba
Fix Marshal examples ( #178 )
...
* Fix Marshal examples
* Move ExampleMarshal to doc test
2017-08-16 17:06:23 -07:00
Thomas Pelletier
69d355db53
Lex performance improvement ( #176 )
...
* Use []token instead of chan token
name old time/op new time/op delta
ParseToml-8 1.18ms ± 0% 0.91ms ± 0% -22.98%
UnmarshalToml-8 1.29ms ± 0% 0.95ms ± 0% -25.96%
name old alloc/op new alloc/op delta
ParseToml-8 429kB ± 0% 444kB ± 0% +3.49%
UnmarshalToml-8 451kB ± 0% 466kB ± 0% +3.32%
name old allocs/op new allocs/op delta
ParseToml-8 14.1k ± 0% 13.7k ± 0% -2.31%
UnmarshalToml-8 15.1k ± 0% 14.7k ± 0% -2.16%
* Lex on []byte instead of io.Reader
name old time/op new time/op delta
ParseToml-8 1.18ms ± 0% 0.29ms ± 0% -75.18%
UnmarshalToml-8 1.27ms ± 0% 0.38ms ± 0% -70.38%
name old alloc/op new alloc/op delta
ParseToml-8 429kB ± 0% 135kB ± 0% -68.53%
UnmarshalToml-8 451kB ± 0% 157kB ± 0% -65.22%
name old allocs/op new allocs/op delta
ParseToml-8 14.1k ± 0% 3.2k ± 0% -77.20%
UnmarshalToml-8 15.1k ± 0% 4.2k ± 0% -72.00%
2017-06-27 18:26:37 -07:00
Jordan Krage
ef23ce9e92
WriteTo string concat allocation reduction ( #177 )
...
* reduce string concat allocs in Tree.writeTo
* fix failingWriter and usages
2017-06-27 18:24:37 -07:00
Thomas Pelletier
4a000a21a4
Benchmark against other libraries ( #175 )
...
BenchmarkUnmarshalToml-8 1000 1320117 ns/op 450932 B/op 15072 allocs/op
BenchmarkUnmarshalBurntSushiToml-8 3000 402897 ns/op 82900 B/op 1761 allocs/op
BenchmarkUnmarshalJson-8 20000 66092 ns/op 3536 B/op 101 allocs/op
BenchmarkUnmarshalYaml-8 10000 189600 ns/op 44872 B/op 1058 allocs/op
2017-06-25 13:05:13 -07:00
Thomas Pelletier
fe7536c3de
Run benchmarks and fmt in travis ( #174 )
2017-06-01 23:55:32 -07:00
Thomas Pelletier
e94d595cd4
Update tested Go versions ( #173 )
2017-06-01 21:42:09 -07:00
Thomas Pelletier
0d5a6db8dd
Fix toString float encoding ( #172 )
...
Ensure a round float does contain a decimal point. Otherwise
feeding the output back to the parser would convert to an integer.
Fixes #171
2017-06-01 21:36:58 -07:00
Cameron Moore
a60c71373e
Optimize some string handling ( #170 )
...
* Don't use fmt.Sprintf on simple strings
* Use bytes.Buffer in encodeTomlString
name old time/op new time/op delta
Lexer-8 162µs ± 0% 161µs ± 0% -0.12%
TreeToTomlString-8 19.7µs ± 0% 7.5µs ± 0% -61.80%
name old alloc/op new alloc/op delta
TreeToTomlString-8 9.75kB ± 0% 4.96kB ± 0% -49.12%
name old allocs/op new allocs/op delta
TreeToTomlString-8 485 ± 0% 78 ± 0% -83.92%
2017-06-01 21:03:55 -07:00
Thomas Pelletier
5ccdfb18c7
Write empty tables as well ( #169 )
...
Empty tables are allowed by the spec, so they should not be removed:
[[empty-tables]]
[[empty-tables]]
is perfectly valid.
Fixes #163
v1.0.0
2017-05-30 18:35:27 -07:00
Thomas Pelletier
40ecdac242
Clean up documentation ( #168 )
...
Fixes #135
2017-05-30 18:33:25 -07:00
Albert Nigmatzianov
26ae43fdee
Use bytes.Buffer for tomlLexer.buffer ( #166 )
...
* Use bytes.Buffer for tomlLexer.buffer
* Add BenchmarkLexer
Fix #165
name old time/op new time/op delta
Lexer-4 343µs ± 1% 331µs ± 1% -3.56% (p=0.000 n=20+19)
name old alloc/op new alloc/op delta
Lexer-4 55.8kB ± 0% 50.8kB ± 0% -8.86% (p=0.000 n=20+20)
name old allocs/op new allocs/op delta
Lexer-4 2.01k ± 0% 1.84k ± 0% -8.46% (p=0.000 n=20+20)
2017-05-30 10:27:36 -07:00
Jordan Krage
048765b449
Switch kindToTypeMapping from map to array ( #164 )
...
Improve lookup performance by 8x.
2017-05-25 09:02:42 -07:00
Cameron Moore
5c26a6ff6f
Fix Tree.ToMap godoc comment ( #162 )
...
Fixes #160
2017-05-16 10:14:30 -07:00
Thomas Pelletier
685a1f1cb7
Rename TomlTree to Tree ( #159 )
...
Avoid stutter.
Fixes #55
2017-05-10 17:53:23 -07:00
Thomas Pelletier
23f644976a
Move query to its own subpackage ( #152 )
...
Move all the query system to its own package. The reason is to
avoid it to rely on unexported methods and structures, and move
it out of the main package since this is really not a core
feature. It is still tied to the toml.TomlTree and toml.Position
structures for now.
* Move query mechanism to its own subpackage
* Rename QueryResult to Result to avoid stutter
* Add query.CompileAndExecute
Fixes #116
2017-05-07 17:14:13 -07:00
Thomas Pelletier
64bc956d5e
Remove clean.sh ( #158 )
2017-05-07 16:09:32 -07:00
John K. Luebs
53be957dac
Allow unmarshal from any TomlTree ( #157 )
...
Fixes #153
2017-05-07 15:55:38 -07:00
Kevin Burke
97253b98df
Fix plural mistake in Set* docs ( #154 )
2017-05-03 21:03:14 -07:00
Kevin Burke
76c552dcd7
Initialize keys array to final length ( #155 )
...
Previously we'd create an empty array and need to continuously resize
it as we appended more entries. This way we immediately create the
correct size array, and then add entries to it.
2017-05-03 21:02:36 -07:00
Carolyn Van Slyck
fe206efb84
Provide Marshaler interface ( #151 )
...
The toml.Marhshaler interface allows marshalling custom objects implementing
the interface. Design based off json.Marshaler.
2017-04-04 18:41:05 -07:00
tro3
e32a2e0474
Reflection-based marshaling / unmarshaling ( #149 )
...
Fixes #146
2017-03-29 14:49:41 -07:00
Thomas Pelletier
f6e7596e8d
Reflect actual slice type in TreeFromMap ( #145 )
...
* Reflect actual slice type in TreeFromMap
* Fix writeTo for slices tomlValues
Fixes #143
2017-03-23 11:20:46 +01:00
tro3
25e50242f6
Fix TestMissingFile on Windows ( #148 )
...
Closing #147
2017-03-21 15:10:48 +01:00
Albert Nigmatzianov
62e2d802ed
Fix #141 ( #142 )
...
* Use String() of key if it exists during TreeFromMap
2017-03-21 10:01:44 +01:00
Thomas Pelletier
fee7787d3f
Rework tree from map ( #139 )
...
* Make TreeFromMap reflect to construct tree
* Fix wording of invalid value type in writeTo
Fixes #138 , #139 , #134
⚠️ TreeFromMap signature changed to `TreeFromMap(map[string]interface{}) (*TomlTree, error)`
2017-03-14 13:16:40 -07:00
Cameron Moore
3b00596b2e
Support lowercase unicode escape sequences ( #140 )
2017-03-13 20:04:08 -07:00
Thomas Pelletier
13d49d4606
Fix coveralls ( #136 )
v0.5.0
2017-03-02 09:43:01 -08:00
Thomas Pelletier
7e6e4b1314
Rewrite TomlTree encoding ( #133 )
...
* Rewrite `TomlTree` encoding
* Introduce `TomlTree.WriteTo`
2017-03-02 09:17:06 -08:00
Thomas Pelletier
3616783228
Run go vet as part of the test suite ( #132 )
...
* Run go vet as part of the test suite
2017-02-27 14:29:04 -08:00
Thomas Pelletier
d0ec4317d3
Fix compatibility with latest go-buffruneio ( #131 )
2017-02-27 14:18:12 -08:00
Thomas Pelletier
22139eb546
Test with go 1.8 ( #129 )
2017-02-16 17:27:36 -08:00
Thomas Pelletier
c9506ee963
Update license ( #128 )
...
* Update LICENSE badge
* Update license year to 2017
2017-02-09 13:38:35 -08:00
David Brown
3a6d01f7a0
Fix syntax errors in package-level documentation ( #126 )
2017-02-09 13:23:28 -08:00
Thomas Pelletier
d1fa2118c1
Bump test go to 1.7.5 ( #127 )
...
* Bump test go to 1.7.5
* Use travis container infrastructure
* Don't run the tests twice on PRs
2017-02-03 13:36:21 -08:00
Thomas Pelletier
a1f048ba24
Make ToString() return an error instead of panic ( #117 )
...
Fixes #100
2017-01-15 18:49:11 -08:00
Jordan Bach
ee2c0b51cf
Fix typo in README tomljson installation instructions ( #125 )
2017-01-15 18:48:04 -08:00
Thomas Pelletier
439fbba1f8
Make lexComment jump back to the previous state ( #122 )
...
When a comment appears in an rvalue, the lexer needs to jump back to
lexRValue, not to lexVoid.
Fixes #120 .
2016-12-29 19:51:04 +01:00