talira

Read and write TOML 1.1 in Go, with an encoding/json-style API

open sourceMITfree

go-toml is a Go library for reading and writing TOML, supporting TOML v1.1.0. It works like the standard library's encoding/json, with a strict mode that errors on keys the target struct doesn't have, decoding errors that show the offending line in context, local date and time types, and output with comments for generated config files. It also ships three command-line tools: tomljson (TOML to JSON), jsontoml (JSON to TOML) and tomll (lint and reformat TOML), also as a Docker image.

Problems it solves

  • parse a TOML config file into Go structs
  • catch typos in a TOML config by failing on unknown keys in Go
  • convert a TOML file to JSON on the command line

Features

  • TOML v1.1.0 support
  • Marshal and Unmarshal like encoding/json
  • strict mode that rejects unknown keys
  • contextualized decode errors that show the offending line
  • LocalDate, LocalTime and LocalDateTime types
  • commented output for generated config files
  • tomljson, jsontoml and tomll command-line tools and Docker image

Alternatives

The same job

These do what go-toml does.

  1. toml (BurntSushi) Decode and encode TOML in Go, like encoding/json

Compare go-toml with the top 3