A TOML parser and JSON encoder.
Installation:
go get github.com/komkom/toml
Since the parser transforms a toml in stream into a valid json, normal json unmarshaling from the std lib can be used.
doc := `
[some]
toml="doc"`
dec := json.NewDecoder(toml.New(bytes.NewBufferString(doc)))
st := struct {
Some struct {
Toml string `json:"toml"`
} `json:"some"`
}{}
err := dec.Decode(&st)
if err != nil {
panic(err)
}
fmt.Printf("toml: %v\n", st.Some.Toml)
In the repo there are two benchmarks comparing throughputs of just reading data from memory versus also transforming and parsing the data. The parser slows down data throughput around 15x here. These benchmarks are by no means thorough and only hints at an estimate.
Parser Throughput 7.05 MB/s
Memory Throughput 100.03 MB/s