Getting Started
Installation

Installation

Requirements

  • Go 1.21 or higher
  • A supported database (PostgreSQL, MySQL, SQLite, or DuckDB)

Install lit

go get github.com/tracewayapp/lit/v2

Database 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/pq

MySQL

go get github.com/go-sql-driver/mysql

SQLite

go get github.com/mattn/go-sqlite3

DuckDB

go get github.com/marcboeker/go-duckdb/v2

DuckDB 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.go

If you see "lit installed successfully!", you're ready to proceed to the Quick Start.