Repository navigation
Home
Arne K. (TRC-Loop) edited this page Nov 14, 2026
·
5 revisions
rustyon is a Go implementation of Rusty Object Notation (RON), the human-readable serialization format used in the Rust ecosystem. It is an independent implementation and is not affiliated with the ron-rs project.
// Read and write files like this from Go.
#![enable(implicit_some)]
GameConfig(
window_size: (800, 600),
window_title: "Rusty Game",
difficulty: Hard,
spawn: Circle(radius: 2.5),
key_bindings: {"up": Up, "down": Down},
)-
MarshalandUnmarshalwith anencoding/jsonstyle API, plusMarshalIndent, a streamingEncoderandDecoder, andMarshaler/Unmarshalerinterfaces. -
Rust naming by default. Go field names become
snake_case(MaxHPismax_hp), so Go structs line up with Rust structs without tags. Other strategies (camelCase,PascalCase,kebab-case, ...) can be set per call or per struct withrename_all. Struct tags support renaming,omitempty,omitzero,flatten,-, struct names and tuple structs. -
Layout control.
PrettyConfigmirrors ron-rs: compact lists, depth limit, escaped non-ASCII, numbered list elements. See Pretty Printing. -
Raw values.
rustyon.Rawkeeps one value as text for later decoding;UnmarshalAs[T]returns the value directly. -
Option and the RON extensions. Pointers map to
Option(None/Some(v)). The encoder can writeimplicit_someandunwrap_newtypesoutput; the decoder always accepts both forms. -
Rust enums on Go interfaces. Register variants once and
Circle(radius: 1.0)decodes into yourCircletype. Unit, tuple, struct and newtype variants are supported, as are serde's internally tagged, adjacently tagged and untagged forms, and data-less enums can map onto Go constants. -
Dynamic
Valuetree for documents of unknown shape, including 128-bit integers, ordered maps and struct names. -
Formatter that keeps comments, like
gofmtfor.ronfiles. It keeps number spellings, raw strings and your choice between one-line and multi-line collections. -
Full ron-rs grammar: raw strings, byte strings, byte literals, nested block comments, number suffixes, raw identifiers, ranges and
#![enable(...)]attributes. The parser matches ron-rs 0.12.3 exactly, checked by a differential test suite against a Rust oracle. -
Comment-preserving edits.
ParseEditablechanges, adds and deletes values by path (users[0].name) and leaves comments, number spellings and layout alone. See Editing. -
JSON conversion in the
ronjsonpackage, and arustyonCLI to format, validate, query (get) and convert files to and from JSON, YAML and TOML, withfile:line:colerrors that show the source line and a caret. - Zero dependencies, Go 1.24 or newer.
go get github.com/peltonapp/rustyon-goThe module path ends in rustyon-go, but the package name is rustyon:
import "github.com/peltonapp/rustyon-go" // package rustyon
err := rustyon.Unmarshal(data, &cfg)The JSON helpers live in a sub package:
import "github.com/peltonapp/rustyon-go/ronjson"The command line tool installs with:
go install github.com/peltonapp/rustyon-go/cmd/rustyon@latestThe CLI is a separate Go module, so its YAML and TOML dependencies never reach your build. See CLI for install details.
type Config struct {
WindowTitle string // matches window_title
WindowSize [2]int // matches (800, 600)
MaxFPS *int // Option<u32>: None or Some(60)
Tags []string `ron:"labels,omitempty"`
}
var c Config
err := rustyon.Unmarshal(data, &c)
out, err := rustyon.MarshalIndent(c, "", " ")Getting Started walks through the API step by step.
| Page | What it covers |
|---|---|
| Getting Started |
Unmarshal, Marshal, MarshalIndent, MarshalWith, Encoder and Decoder with all their options |
| Type Mapping | How every Go type maps to RON and back, decoding into any, custom marshalers, Raw values, UnmarshalAs
|
| Struct Tags | Field naming strategies (camelCase, rename_all, ...), ron:"..." tags, flatten, tuple structs, newtypes, embedded structs |
| Enums | Rust enums as Go interfaces, RegisterEnum, internally tagged, adjacently tagged and untagged enums, RegisterUnitEnum, registries |
| Pretty Printing |
PrettyConfig and MarshalWithConfig: compact lists, depth limit, escaped non-ASCII, custom indent and line breaks |
| Value Tree |
Parse, ParseDocument and the dynamic Value types |
| Formatter |
Format and FormatIndent layout rules with before and after examples |
| Editing |
ParseEditable and Editable: change values, add and delete fields in place while keeping comments and layout |
| CLI | The rustyon command: fmt, validate, get, and conversion to and from JSON, YAML and TOML |
| JSON Conversion | The ronjson package and what is lost on the way to JSON |
| RON Syntax | Reference of the RON grammar this library accepts |
| Errors | Every error type and how to inspect it with errors.As
|
| Performance | Benchmarks and performance notes |
- API reference: pkg.go.dev/github.com/peltonapp/rustyon-go
- The RON format and the Rust implementation: github.com/ron-rs/ron
- The Rust crate documentation: docs.rs/ron
rustyon is licensed under the BSD-3-Clause license. It is an independent implementation of RON and is not affiliated with the ron-rs project.