DEV.co
Open-Source Databases · go-reform

reform

Reform is a Go ORM that prioritizes type safety and compile-time checking through code generation rather than runtime reflection. It supports PostgreSQL, MySQL, SQLite, and SQL Server, and uses non-empty interfaces to enforce correct API usage.

Source: GitHub — github.com/go-reform/reform
1.5k
GitHub stars
74
Forks
Go
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorygo-reform/reform
Ownergo-reform
Primary languageGo
LicenseMIT — OSI-approved
Stars1.5k
Forks74
Open issues88
Latest releasev1.5.1 (2021-08-27)
Last updated2025-12-15
Sourcehttps://github.com/go-reform/reform

What reform is

Reform generates type-safe database models from SQL schemas using `go generate`, leveraging initialization-time reflection and non-empty interfaces. It avoids `interface{}` patterns and runtime type sidestepping, providing explicit methods like `FindByPrimaryKeyFrom()` and `Save()` with proper type signatures.

Quickstart

Get the reform source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/go-reform/reform.gitcd reform# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Type-Safe Database Access in Go Services

Ideal for backend services where compile-time type safety is critical. Reform's code-generated models catch schema mismatches and incorrect column access at compile time, reducing production bugs.

Multi-Database Schema-Driven Development

Excellent for teams maintaining multiple SQL dialects (PostgreSQL, MySQL, SQLite, SQL Server). The `reform-db` tool auto-generates models from existing schemas, reducing manual boilerplate.

Simple, Predictable CRUD Operations

Well-suited for applications with straightforward insert/update/delete/select patterns. Reform's explicit, non-magical API makes database behavior transparent and testable.

Implementation considerations

  • Requires Go 1.17+; uses `go generate` workflow—ensure team is familiar with code generation patterns and CI integration.
  • Initial setup involves running `reform-db` to introspect existing schema; model generation is one-time cost but schema changes require regeneration.
  • Pointer types recommended for nullable columns (`*string`, `*time.Time`) to distinguish NULL from zero values; integration with helper packages like `github.com/AlekSi/pointer` advised.
  • Primary key field cannot be a pointer; design schema accordingly and be aware of the zero-value limitation for PK columns.
  • Generated code is separate from hand-written models; maintain clear separation between `person.go` and `person_reform.go` to avoid merge conflicts.

When to avoid it — and what to weigh

  • Complex Query Requirements or Aggregations — Reform is not designed for complex analytical queries or advanced SQL patterns. Limitations on composite primary keys and the simpler query builder may require falling back to raw SQL.
  • High-Velocity Schema Evolution — Regenerating models on every schema change can be friction-heavy in fast-moving prototypes. Real-time schema changes require re-running `reform-db` and regenerating code.
  • Need for Advanced ORM Features — Reform intentionally avoids lazy loading, query hooks, and other advanced ORM conveniences. Projects needing rich ORM ecosystems (e.g., relationships, lifecycle hooks) should consider alternatives like gorm or ent.
  • Zero Primary Key Support Required — Reform requires exactly one primary key per record and does not support composite keys or zero-value primary keys. Tables without a single PK column are not well-supported.

License & commercial use

MIT License (standard permissive open-source license). Copyright held by Alexey Palazhchenko (2016–2020). Generated code is explicitly permitted under terms of your choice.

MIT License permits unrestricted commercial use, modification, and distribution, provided license and copyright notice are retained. No proprietary restrictions or commercial licensing required. Suitable for proprietary products.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceModerate
DocumentationAdequate
License clarityClear
Deployment complexityLow
DEV.co fitGood
Assessment confidenceHigh
Security considerations

Reform uses parameterized queries via `database/sql`, mitigating SQL injection. No cryptographic or authentication features claimed. Security posture depends on underlying driver and database configuration. Review generated code and input validation in application logic. No recent security advisories mentioned; consider audit if processing sensitive data.

Alternatives to consider

GORM

Feature-rich, popular Go ORM with hooks, associations, eager loading, and more flexible query API. Best if you need advanced ORM capabilities and don't mind runtime reflection.

sqlc

Query-first code generator; generates type-safe Go code from hand-written SQL queries. Better for complex queries but requires manual SQL and separate code generation step.

ent

Schema-first entity framework with code generation; supports relationships, middleware, and schema versioning. More feature-complete but higher learning curve than reform.

Software development agency

Build on reform with DEV.co software developers

If you prioritize compile-time type safety and simple, predictable CRUD patterns over advanced ORM features, schedule a technical review to assess Reform's fit for your schema and query patterns.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

reform FAQ

Does Reform support relationships or foreign keys?
Not explicitly. Reform focuses on simple record-level operations. Relationships must be managed manually or via raw SQL queries. This is by design to keep the library simple.
Can I use Reform with an existing database schema?
Yes. The `reform-db` command introspects your existing database and generates models for tables and views. You can then customize generated models as needed.
Do I need to regenerate models every time the schema changes?
Yes. Running `reform-db` or `go generate` regenerates models. You should re-run after schema migrations. Some teams automate this in CI or pre-commit hooks.
How does Reform handle NULL values?
Use pointer types (`*string`, `*int64`) or `sql.NullXXX` types for nullable columns. Pointers are recommended as they clearly distinguish NULL from zero values.

Custom software development services

Adopting reform is usually one piece of a larger software development effort. As a software development agency, DEV.co provides software development services and web development expertise — pairing senior software developers and web developers with your team to design, build, and operate open-source databases software in production.

Evaluate Reform for Your Go Backend

If you prioritize compile-time type safety and simple, predictable CRUD patterns over advanced ORM features, schedule a technical review to assess Reform's fit for your schema and query patterns.