Struct Decomposition for Go. Type-Safe Without T.
Break structs into typed maps so infrastructure code can read, write, and transform fields without importing your types.
Get Startedimport "github.com/zoobz-io/atom"
type User struct {
ID string
Name string
Age int64
Balance float64
Active bool
}
atomizer, _ := atom.Use[User]()
a := atomizer.Atomize(&User{
ID: "usr-1", Name: "Alice", Age: 30, Balance: 100.50, Active: true,
})
// Type-segregated maps — no interface{}, no reflection at access time
a.Strings["ID"] // "usr-1"
a.Strings["Name"] // "Alice"
a.Ints["Age"] // 30
a.Floats["Balance"] // 100.50
a.Bools["Active"] // true
// Infrastructure code never imports User
storage.Save(a) // storage works with typed maps
validator.Check(a) // validator reads fields directly
migrator.Upgrade(a) // migrator transforms field-by-field
// Reconstruct when you need the original type back
restored, _ := atomizer.Deatomize(a)Why Atom?
The bridge between your domain types and the infrastructure that operates on them.
Type Segregation
Fields sorted into Strings, Ints, Floats, Bools, Times, Bytes. Each map carries only its type — no interface{} maps.
Infrastructure Decoupling
Libraries accept atoms, not your structs. Storage, validation, and migration work without importing domain types.
Spec-Driven Introspection
Query field names, types, and table assignments at runtime. Know your data shape without the original struct.
Width Normalization
int8 through int64 all land in Ints. float32 and float64 in Floats. Overflow detected on reconstruction.
Three Performance Paths
Reflection for convenience, interfaces for control, code generation for speed. Same API, same result.
Nested Composition
Recursive atoms for complex object graphs. Each nested level carries its own Spec and typed maps.
Capabilities
Decompose, inspect, transform, and reconstruct Go structs through typed maps.
| Feature | Description | Link |
|---|---|---|
| Atomize | Decompose any struct into typed maps with a single call. Registration is cached per type. | Quickstart |
| Deatomize | Reconstruct the original struct from an atom with width overflow detection. | Basic Usage |
| Custom Interfaces | Implement Atomizable/Deatomizable for computed fields, encryption, or schema migration. | Interfaces |
| Named Types | type UserID string, type Status int — semantics preserved through round-trip decomposition. | Custom Types |
| Nullable Fields | Separate pointer tables with explicit nil handling. StringPtrs, IntPtrs, and friends. | Tables |
| Field Introspection | Fields(), FieldsIn(table), TableFor(field), Spec() — full runtime queryability of your type layout. | API |
Articles
Browse the full atom documentation.