Commit Graph

28 Commits

Author SHA1 Message Date
x-hgg-x 19eb8cf036 Fix various quoted keys bugs (#400)
Fixes #396 #397 #398 #399
2020-05-06 23:13:18 -04:00
Allen c5fbd3eba6 Add support of mixed-type array (#376)
Fixes #357
2020-05-06 23:07:57 -04:00
x-hgg-x 82a6a1977d Add indentation setting for Encoder (#386)
Fixes #371
2020-05-04 13:21:22 -04:00
Allen a30fd2239c Escape adjacent quotation marks marshaling in multiline string (#365) 2020-04-24 21:38:04 -04:00
Allen a12e102214 Fix multiline + non-primitive commenting (#336)
Fixes #216
2020-03-16 22:51:47 -04:00
Thomas Pelletier 5e74bb91ea Local time support (#318) 2019-10-25 14:28:32 -04:00
Thomas Pelletier 3a4d7af89e Local DateTime support (#317) 2019-10-25 14:07:46 -04:00
Thomas Pelletier 8a362ad712 Short-date support (#298) 2019-10-25 13:21:44 -04:00
Marcin Białoń 75654e60b8 Tree.Marshal returns the TOML encoding of Tree (#306)
The Tree.Marshal tried to marshal the Tree struct itself rather than the nodes being part of the tree.

Fixes #295
2019-09-26 13:39:15 -07:00
Chris 3ded2e09ee Fix float64 truncation error (#293)
Don't truncate float64 representation on marashaling.

Fixes https://github.com/pelletier/go-toml/issues/289
2019-08-26 20:57:02 -07:00
Thomas Pelletier 68063a447e Quote keys during encoding when the key isn't bare (#291)
In case the key contains non-bare characters (out of `A-Za-z0-9_-`), the
key needs to be quoted during encoding to be valid TOML.
2019-08-18 23:00:12 -07:00
Ceriath 51edd0ca49 Fix goreportcard issues (#271)
* Fixed misspell

* Fixed ineffassign

`user` and `password` always got overwritten
`orderedVals` was initialized with an empty array but always got overwritten by either `sortByLines()` or `sortAlphabetical`
`err` was assigned a `nil` value that was either overwritten or unused anyways

* Fix comment for DeletePath

The comment assumed the method was named Delete, i guess a rename happened at some point

* Update doc_test.go
2019-04-11 12:11:29 +01:00
Brent DeSpain 63909f0a90 Option to keep fields ordered when marshal struct (#266)
Adds a new `Order()` option to preserve order of struct fields when
marshaling.
2019-04-02 09:47:51 -07:00
Alan Murtagh c01d1270ff Multiline Marshal tag (#221)
The new multiline tag works just like the existing 'commented' tag (i.e.
`multiline:"true"`), and tells go-toml to marshal the value as a
multi-line string. The tag currently has no impact on any non-string
fields.
2018-06-05 13:47:19 -07:00
Chris 05bcc0fb0d Make multi-line arrays always use trailing commas (#217)
This makes ArraysWithOneElementPerLine output arrays with commas after every element.

```
A = [1,2,3]
```

Now becomes:

```
A = [
  1,
  2,
  3,
]
```
2018-02-28 15:36:31 -08:00
Jelte Fennema 778c285afa Add support for special float values (inf and nan) (#210) 2018-01-18 14:10:55 -08:00
Thomas Pelletier b8b5e76965 Add Encoder opt to emit arrays on multiple lines (#203)
A new Encoder option emits arrays with more than one line on multiple lines.
This is off by default and toggled with `ArraysWithOneElementPerLine`.

For example:

```
A = [1,2,3]
```

Becomes:

```
A = [
  1,
  2,
  3
]
```

Fixes #200
2017-12-18 14:57:16 +01:00
Yvonnick Esnault 690dbc9ee7 Comment annotation for Marshal (#185) 2017-10-01 15:05:24 -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 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
2017-05-30 18:35:27 -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
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
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
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
Thomas Pelletier 7e6e4b1314 Rewrite TomlTree encoding (#133)
* Rewrite `TomlTree` encoding
* Introduce `TomlTree.WriteTo`
2017-03-02 09:17:06 -08:00