explaingit

go-jet/jet

Analysis updated 2026-07-03

3,669GoAudience · developerComplexity · 3/5Setup · moderate

TLDR

Jet is a Go library for writing SQL queries as type-safe Go code. A code generator reads your database schema so the compiler catches column name typos and type mismatches before your app runs.

Mindmap

mindmap
  root((repo))
    What it does
      Type-safe SQL
      Code generation
      Result mapping
    Databases
      PostgreSQL
      MySQL
      SQLite
    Features
      Window functions
      Subqueries
      Struct mapping
    Audience
      Go developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Write database queries in Go where the compiler catches column name typos and type mismatches before the app runs.

USE CASE 2

Generate Go types from a PostgreSQL or MySQL schema so your editor autocompletes table and column names.

USE CASE 3

Run complex SQL with window functions, subqueries, and CTEs using Go code instead of raw SQL strings.

USE CASE 4

Map SQL query results directly into nested Go structs without writing manual scan code.

What is it built with?

GoPostgreSQLMySQLSQLite

How does it compare?

go-jet/jethoanhan101/algomicrocosm-cc/bluemonday
Stars3,6693,6693,669
LanguageGoGoGo
Setup difficultymoderateeasyeasy
Complexity3/51/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires running the code generator against a live database before writing your first query.

In plain English

Jet is a Go library for interacting with SQL databases. It solves a specific frustration that comes up when writing database queries in Go: most approaches require either writing raw SQL strings (which the compiler cannot check for mistakes) or using an ORM that hides SQL behind a different abstraction. Jet takes a middle path. You write queries that look like SQL, but they are written as Go code, so the compiler catches typos and type mismatches before your program ever runs. The workflow has two steps. First, you run a code generator that connects to your database and reads its structure: the tables, columns, views, and enums. It writes Go files representing those structures. Second, you use those generated types to build queries in Go code. Because the generated types match your actual database schema, your editor can autocomplete column names, and the compiler will flag any query that references a column or table that does not exist. Supported databases are PostgreSQL, MySQL, and SQLite, along with compatible databases that use the same protocols, such as CockroachDB and MariaDB. The library handles all the standard SQL operations: SELECT, INSERT, UPDATE, DELETE, WITH clauses, window functions, subqueries, and locking statements. When you execute a query, Jet maps the results directly into Go structs that you define, including nested structs for joined data. The README explicitly notes that Jet is not an ORM. It does not manage relationships, migrations, or model lifecycle. It is specifically a query builder and result mapper, meaning you still write logic that resembles SQL rather than calling object methods like save() or find(). Installation requires Go 1.24 or later. You add Jet as a dependency with a single go get command and install the generator separately with go install. The README includes a full walkthrough using a sample DVD rental database to demonstrate how generation, query writing, and result mapping work together. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
Using go-jet with PostgreSQL, show me how to generate Go types from my database schema and write a SELECT with a JOIN that maps results into nested Go structs.
Prompt 2
How do I write an INSERT query with go-jet in Go and get back the inserted row's ID?
Prompt 3
Show me a go-jet query in Go that uses a window function to rank rows by a score column in a PostgreSQL table.
Prompt 4
How do I set up the go-jet code generator to read a MySQL database schema and output Go files to a specific directory?

Frequently asked questions

What is jet?

Jet is a Go library for writing SQL queries as type-safe Go code. A code generator reads your database schema so the compiler catches column name typos and type mismatches before your app runs.

What language is jet written in?

Mainly Go. The stack also includes Go, PostgreSQL, MySQL.

How hard is jet to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is jet for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub go-jet on gitmyhub

Verify against the repo before relying on details.