{"id":51458799,"url":"https://github.com/mochams/glimt","last_synced_at":"2026-07-06T03:30:24.436Z","repository":{"id":344273191,"uuid":"1180664249","full_name":"mochams/glimt","owner":"mochams","description":"SQL-first queries with composable filters for Go","archived":false,"fork":false,"pushed_at":"2026-03-13T22:32:07.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-14T10:28:53.050Z","etag":null,"topics":["go","golang","sql","sql-query"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/mochams/glimt","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mochams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-13T09:25:20.000Z","updated_at":"2026-03-13T22:31:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mochams/glimt","commit_stats":null,"previous_names":["mochams/glimt"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mochams/glimt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mochams%2Fglimt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mochams%2Fglimt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mochams%2Fglimt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mochams%2Fglimt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mochams","download_url":"https://codeload.github.com/mochams/glimt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mochams%2Fglimt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35177220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-06T02:00:07.184Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","sql","sql-query"],"created_at":"2026-07-06T03:30:19.985Z","updated_at":"2026-07-06T03:30:24.417Z","avatar_url":"https://github.com/mochams.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Glimt\n\n![GoDoc](https://pkg.go.dev/badge/github.com/mochams/glimt.svg)\n\n**Glimt** is a lightweight SQL toolkit for Go that keeps queries in `.sql` files\nwhile allowing **safe runtime composition of predicates**.\n\nMany applications prefer writing SQL in `.sql` files instead of embedding\nlarge queries directly in code. However, APIs still need to dynamically add:\n\n- filters\n- search conditions\n- pagination\n\nGlimt keeps your **core SQL declarative**, while allowing **flexible runtime query composition**:\n\n```sql\n-- :name listUsers\nSELECT * FROM users\n```\n\n```go\nimport gl \"github.com/mochams/glimt\"\n\nreg := gl.NewRegistry(gl.DialectPostgres)\n\nusers := reg.MustGet(\"listUsers\").Where(gl.Eq(\"status\", \"active\"))\nusers.Where(gl.Eq(\"role\", \"admin\"))\nusers.Limit(10)\nusers.Offset(2)\n\nsql, args := users.Build()\n```\n\nGenerated SQL (Postgres):\n\n```sql\nSELECT * FROM users\nWHERE status = $1 AND role = $2\nLIMIT $3 OFFSET $4\n```\n\nGenerated Args:\n\n```txt\n[\"active\", \"admin\", 10, 2]\n```\n\nGlimt lets you **write SQL once and compose predicates dynamically.**\n\nInstallation\n\n```bash\ngo get github.com/mochams/glimt\n```\n\nDefine queries in `.sql` files and load them by name.\n\n```sql\n-- :name listUsers\nSELECT * FROM users\n```\n\n```go\nreg := gl.NewRegistry(gl.DialectPostgres)\n\nreg.LoadFile(\"queries/users.sql\")\n\nadmins, args := reg.MustGet(\"listUsers\").\n    Where(gl.Eq(\"role\", \"admin\")).\n    Limit(10).\n    Build()\n\nuser, args := reg.MustGet(\"listUsers\").\n    Where(gl.Eq(\"id\", \"user_id\")).\n    Limit(1).\n    Build()\n```\n\nWork seamlessly with Go's `embed`.\n\n```go\n//go:embed queries\nvar sqlFiles embed.FS\n\nreg := gl.NewRegistry(gl.DialectPostgres)\n\nreg.LoadFS(sqlFiles, \"queries\")\n```\n\nGlimt lets you build queries directly in Go when needed\n\n```go\nreg := gl.NewRegistry(gl.DialectPostgres)\n\nsql, args := reg.Query(\"SELECT * FROM users\").\n    Where(gl.And(\n        gl.Eq(\"status\", \"active\"),\n        gl.Gt(\"age\", 18),\n    )).\n    OrderBy(\"created_at DESC\").\n    Limit(20).\n    Offset(0).\n    Build()\n```\n\nQueries are defined using `-- :name` annotations.\n\n```sql\n-- :name listUsers\nSELECT * FROM users\n\n-- :name deleteUser\nDELETE FROM users WHERE id = ?\n```\n\nQuery names must be unique across all loaded files.\n\nFor dynamic filtering, avoid writing a top-level `WHERE` clause in the base query.\nInstead attach conditions through the builder:\n\n```sql\n-- :name listUsers\nSELECT * FROM users\n```\n\n```go\nadmins := reg.MustGet(\"listUsers\").\n    Where(gl.Eq(\"role\", \"admin\")).\n    Build()\n\nguests := reg.MustGet(\"listUsers\").\n    Where(gl.Eq(\"role\", \"guest\")).\n    Build()\n```\n\nOne base query, multiple use cases, no duplication.\n\nGlimt automatically writes placeholders for the target database.\n\n\u003ctable style=\"width: 100%;\"\u003e\n  \u003ctr\u003e\n    \u003cth\u003eDatabase\u003c/th\u003e\n    \u003cth\u003ePlaceholders\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003ePostgres\u003c/td\u003e\n    \u003ctd\u003e$1, $2, $3\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eMySQL, SQLite\u003c/td\u003e\n    \u003ctd\u003e?, ?, ?\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eSQL Server\u003c/td\u003e\n    \u003ctd\u003e@p1, @p2, @p3\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eOracle\u003c/td\u003e\n    \u003ctd\u003e:1, :2, :3\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nSQL files should always use `?` placeholders. They are rewritten to the correct format at build time.\n\nGlimt aims to stay **SQL-first**, **Composable**, **Lightweight**, and **Dependency-free**\n\nSee the full example in [`example`](example).\n\nFull API documentation is available at:\n\n\u003chttps://pkg.go.dev/github.com/mochams/glimt\u003e\n\nInspiration\n\nGlimt is inspired by **Yesql**, a Clojure library by Kris Jenkins that\nencourages writing SQL in SQL rather than embedding it in application code.\n\nGlimt extends this idea with **composable predicates**, making it easier\nto build dynamic queries for APIs and search endpoints.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmochams%2Fglimt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmochams%2Fglimt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmochams%2Fglimt/lists"}