Insert and fetch database rows by passing Go structs directly instead of writing raw SQL for every table
Run arbitrary SQL queries and have the results automatically populated into a slice of structs
Add pre- and post-operation hooks to run custom logic whenever a row is inserted, updated, or deleted
Use optimistic locking with a version column to prevent two processes from overwriting each other's changes
Development is low-activity and maintained on a best-effort basis, consider active alternatives for new projects.
gorp is a Go library that reduces the repetitive work of reading and writing data to a SQL database. When you build a Go application that needs to store data, you typically write a lot of similar code to convert between Go structs and database rows: insert this struct, update that one, fetch rows and populate these fields. gorp handles that conversion for you based on how your structs are defined. You connect gorp to a database using Go's standard database/sql package, then register your struct types and tell gorp which table each one maps to and which field is the primary key. After that, you can insert, update, delete, and fetch rows by passing struct values directly rather than writing raw SQL for every operation. Auto-incrementing primary keys are read back and set on the struct after an insert. You can also run arbitrary SQL queries and have the results bound into a slice of structs without manual type assertions. The library supports pre and post hooks on insert, update, and delete operations, which lets you run custom logic around data changes. There is optional optimistic locking using a version column, which prevents one process from overwriting changes made by another. Transaction support is included. The README also mentions optional SQL query logging for debugging. gorp works with several SQL databases by using dialect-specific configuration objects, so the same code can run against SQLite, PostgreSQL, MySQL, or others with minimal changes. The maintainers note in the README that development activity is low and the project is maintained on a best-effort basis, with pull requests merged occasionally. The library follows semantic versioning and supports the two most recent major versions of Go. It is available via standard Go module tooling.
← go-gorp on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.