Installation
Requirements
- Go 1.21 or higher
- A supported database (PostgreSQL, MySQL, SQLite, or DuckDB)
Install lit
go get github.com/tracewayapp/lit/v2Database Drivers
lit works with standard database/sql drivers. Install the driver for your database:
PostgreSQL
# pgx (recommended)
go get github.com/jackc/pgx/v5/stdlib
# or pq
go get github.com/lib/pqMySQL
go get github.com/go-sql-driver/mysqlSQLite
go get github.com/mattn/go-sqlite3DuckDB
go get github.com/marcboeker/go-duckdb/v2DuckDB uses ? placeholders like SQLite, but its Go driver does not support
LastInsertId() — lit reads generated ids back with a RETURNING id clause (like
PostgreSQL), so auto-increment id columns should be sequence-backed
(DEFAULT nextval(...)).
You can also use a custom driver to support databases not listed above.
Verify Installation
Create a simple program to verify everything is working:
package main
import (
"fmt"
"github.com/tracewayapp/lit/v2"
)
type User struct {
Id int
Name string
Email string
}
func main() {
lit.RegisterModel[User](lit.PostgreSQL) // or lit.MySQL, lit.SQLite, lit.DuckDB
fmt.Println("lit installed successfully!")
}Run it:
go run main.goIf you see "lit installed successfully!", you're ready to proceed to the Quick Start.