goon
Go implementation of the TOON data format.

goon is a high-performance, strictly compliant Go library and CLI for parsing and generating TOON (The Object-Oriented Notation) data.
Features
- ๐ Fast & Efficient: Built with performance in mind using a custom scanner and recursive descent parser.
- ๐ Marshal/Unmarshal: Direct conversion between Go structs and TOON format with struct tag support (like
encoding/json).
- ๐ Strict Mode: Optional strict validation to ensure your TOON files are perfectly formatted (no tabs, correct indentation).
- ๐ ๏ธ CLI Tools: Includes
goon encode and goon decode for easy integration into existing workflows.
- ๐ฆ Zero Dependencies: The core library has no external dependencies.
Installation
Quick Install (Script)
Linux & macOS
curl -fsSL https://raw.githubusercontent.com/tnfssc/goon/develop/scripts/install.sh | sh
Windows (PowerShell)
irm https://raw.githubusercontent.com/tnfssc/goon/develop/scripts/install.ps1 | iex
Manual Installation
Library
To use Goon in your Go project:
go get github.com/tnfssc/goon
To install the command-line tool:
go install github.com/tnfssc/goon/cmd/goon@latest
Usage
Library
package main
import (
"fmt"
"log"
"github.com/tnfssc/goon/pkg/toon"
)
type Config struct {
Name string `toon:"name"`
Version string `toon:"version"`
Features []string `toon:"features"`
}
func main() {
// Marshal Go struct to TOON (like json.Marshal)
config := Config{
Name: "MyApp",
Version: "1.0.0",
Features: []string{"fast", "reliable", "simple"},
}
toonData, err := toon.Marshal(config, toon.EncodeOptions{IndentSize: 2})
if err != nil {
log.Fatal(err)
}
fmt.Println(string(toonData))
// Unmarshal TOON to Go struct (like json.Unmarshal)
var decoded Config
err = toon.Unmarshal(toonData, &decoded, toon.DecodeOptions{IndentSize: 2})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Decoded: %+v\n", decoded)
}
CLI
Convert JSON to TOON:
goon encode input.json > output.toon
Convert TOON back to JSON:
goon decode input.toon > output.json
Pipe from stdin:
# JSON to TOON
cat data.json | goon encode > data.toon
# TOON to JSON
cat config.toon | goon decode > config.json
# Chain with other tools
curl https://api.example.com/data.json | goon encode > api-data.toon
TOON Syntax Support
Goon supports the full TOON specification, including:
- Key-Value Pairs: Simple
key: value syntax.
- Nested Objects: Indentation-based hierarchy.
- Arrays:
- List format:
key: [length|] followed by - item lines.
- Coming Soon: Inline arrays and tabular arrays.
- Primitives: Strings, numbers, booleans, and null.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add some amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE.md file for details.