TomYAML is a Golang library designed to parse TOML and YAML files into Golang structures. Presently, only TOML parsing is implemented, while YAML parsing is currently in progress and will be available soon.
Parse(io.Reader) TOML- Parses a TOML file from anio.Readerinto aTOMLstructure.TOML.Key() string- Returns the object key of the TOML from the root.TOML.GetObj(key string) TOML- Retrieves theTOMLobject by the specified key from the root (e.g., foo.bar.baz).TOML.String() string- Returns the TOML file as a string, constructed from aTOMLstructure. Currently parsing supports:- comments with
//and# - key-value separators with
:,=Types: int,float- single-line
string, boolean(true|True|TRUE)datetimeAlso complex object fields and relations are parsed correctley.
To install Tomyaml, use go get:
go get github.com/koss-null/tomyamlAlternatively, import it into your project and run:
go mod tidyHere is a basic example:
package main
import "github.com/koss-null/tomyaml"
func main() {
var err error
var ty tomyaml.TomYaml
if ty, err = tomyaml.Parse("path/to/your/file.toml"); err != nil {
panic(err)
}
// TBD
}This will read TOML file into ty structure.
Support for YAML parsing is currently under development and is expected to be implemented soon. Stay tuned for updates.
The name TomYamL is inspired by the delicious Tom Yum soup from Thailand.
This project is licensed under the MIT License - see the LICENSE.md file for details.