encoding/toml: add first implementation of an encoder
For now, all we test is that it can re-encode all the decoder test cases
because it does not yet aim to keep any comments, style, order,
or structure from the original CUE value.
The go-toml library we use is not able to encode its AST nodes to TOML,
so for now we encode as Go "any" values which drop that information.
This will be resolved in the near future via an encoder that produces
TOML syntax directly without going through an "any" phase first.
For the time being, this basic encoder works,
even if it produces unnecessarily verbose output such as
[foo]
[foo.bar]
[foo.bar.'baz.zzz zzz']
one = '1'
rather than the shorter
[foo.bar.'baz.zzz zzz']
one = "1"
Updates #68.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I5012bba77fb77b8bf1dd1d73615d34c3438cd147
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198539
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>