Skip to main content
bob is a SQL query builder and ORM/Factory generator for Go with a focus on code generation and type safety.

Installation

Run directly

nix run github:spotdemo4/nur#bobgen

Add to flake

devShells.default = pkgs.mkShell {
  packages = with pkgs.trev; [
    bobgen
  ];
};

NixOS configuration

environment.systemPackages = [
  pkgs.trev.bobgen
];

Usage

Generate Go code from your database schema:
bobgen psql

Configuration example

Create a bobgen.yaml configuration file:
output: "models"
pkgname: "models"
wipe: true
no-tests: false

postgres:
  dsn: "host=localhost user=postgres dbname=mydb"
  schemas:
    - public
Run the generator:
bobgen psql -c bobgen.yaml

Features

  • Type-safe queries: Generate type-safe Go code from your schema
  • Multiple databases: Support for PostgreSQL, MySQL, and SQLite
  • Factory generation: Create test factories automatically
  • Query builder: Fluent API for building complex queries
  • Code generation: Generate models, queries, and factories

Status

This package is pending inclusion in nixpkgs: NixOS/nixpkgs#420450

Build docs developers (and LLMs) love