sqlc
A code generator that reads your schema and annotated SQL queries and writes type-safe Go for them: a struct per table, a params struct per query, and one method per query on Queries. You write SQL; the generated package is never edited by hand.
Minimal example
-- name: GetRestaurant :one
SELECT id, name, lat, lng, is_active FROM restaurants WHERE id = ?;Learn this concept
Lesson 2.5 · sqlc: SQL first, Go generatedUsed in exercises
Exercise 2.6 · Generate the restaurant and menu queries Exercise 2.10 · GET /v1/restaurants with a cursor Exercise 2.14 · POST /v1/menu/price: price a configured item Exercise 2.17 · GET /v1/restaurants: open status Exercise 2.24 · GET /v1/restaurants: search by name Exercise 2.26 · GET /v1/restaurants: sort by distance Exercise 6.2 · Menu cache and stock updaterPrerequisite conceptsdatabase/sql
RelatedDependency injection