{"id":24083333,"url":"https://github.com/mitranim/gos","last_synced_at":"2025-04-30T18:23:15.625Z","repository":{"id":57524297,"uuid":"254416207","full_name":"mitranim/gos","owner":"mitranim","description":"[MOVED] Tool for mapping between Go structs and plain SQL. Not an ORM.","archived":false,"fork":false,"pushed_at":"2023-03-27T09:30:22.000Z","size":124,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-26T06:56:56.668Z","etag":null,"topics":["go","sql"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/mitranim/gos","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitranim.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2020-04-09T15:57:05.000Z","updated_at":"2023-03-27T09:30:31.000Z","dependencies_parsed_at":"2024-06-20T00:20:07.314Z","dependency_job_id":"4222efd5-6034-458b-88b5-5f065d5a34d4","html_url":"https://github.com/mitranim/gos","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitranim%2Fgos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitranim%2Fgos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitranim%2Fgos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitranim%2Fgos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitranim","download_url":"https://codeload.github.com/mitranim/gos/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251758715,"owners_count":21639091,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","sql"],"created_at":"2025-01-09T23:56:25.034Z","updated_at":"2025-04-30T18:23:15.603Z","avatar_url":"https://github.com/mitranim.png","language":"Go","readme":"**Moved to https://github.com/mitranim/gg**. This repo is usable but frozen.\n\n## Overview\n\n**Go** ↔︎ **S**QL: tool for decoding results into Go structs. Supports streaming.\n\n**Not an ORM**, and should be used **instead** of an ORM, in combination with a simple query builder (see below).\n\nKey features:\n\n* Decodes SQL records into Go structs.\n* Supports nested records/structs.\n* Supports nilable nested records/structs in outer joins.\n* Supports streaming.\n\nSee the full documentation at https://pkg.go.dev/github.com/mitranim/gos.\n\nSee the sibling library https://pkg.go.dev/github.com/mitranim/sqlb: a simple query builder that supports scanning structs into named arguments.\n\n## Differences from [jmoiron/sqlx](https://github.com/jmoiron/sqlx)\n\nGos is somewhat similar to [jmoiron/sqlx](https://github.com/jmoiron/sqlx). Key differences:\n\n* Supports null records in outer joins, as nested struct pointers.\n* Selects fields explicitly, by reflecting on the output struct. This allows _you_ to write `select *`, but if the struct is lacking some of the fields, the DB will optimize them out of the query.\n* Simpler API, does not wrap `database/sql`.\n* Explicit field-column mapping, no hidden renaming.\n* Has only one tiny dependency (most deps in `go.mod` are test-only).\n* ... probably more\n\n## Features Under Consideration\n\n* Short column aliases.\n\nLike many similar libraries, when selecting fields for nested records, Gos relies on column aliases like `\"column_name.column_name\"`. With enough nesting, they can become too long. At the time of writing, Postgres 12 has an identifier length limit of 63 and will _silently truncate_ the remainder, causing queries to fail, or worse. One solution is shorter aliases, such as `\"1.2.3\"` from struct field indexes. We still want to support long alises for manually-written queries, which means the library would have to support _both_ alias types, which could potentially cause collisions. Unclear what's the best approach.\n\n## Changelog\n\n### 0.1.10\n\nImproved how `Query` and `Scanner` handle previously-existing values in the output, especially in regards to pointers.\n\nWhen a row contains `null`, the corresponding Go value is now zeroed rather than ignored. The old non-zeroing behavior was aligned with `encoding/json`. The new behavior diverges from it.\n\nWhen a row contains non-`null` and the corresponding Go value is a non-nil pointer, the value is written to the pointer's target, without replacing the pointer.\n\n### 0.1.9\n\n`Query` allows nil output, using `conn.ExecContext` to discard the result.\n\n### 0.1.8\n\nSupport streaming via `QueryScanner` and `Scanner`.\n\n### 0.1.7\n\nDependency update.\n\n### 0.1.6\n\nBreaking: moved query generation utils into https://pkg.go.dev/github.com/mitranim/sqlb.\n\n### 0.1.5\n\nFixed an oversight in `queryStruct` and `queryScalar` that could lead to shadowing DB errors with `ErrNoRows` in some edge cases.\n\n### 0.1.4\n\nAdded `SqlQuery.QueryAppend`.\n\n### 0.1.3\n\nChanged the license to Unlicense.\n\n### 0.1.2\n\nBreaking changes in named args utils for symmetry with `database/sql`.\n\n* Added `Named()`.\n* Renamed `SqlArg -\u003e NamedArg`.\n* Renamed `SqlArgs -\u003e NamedArgs`.\n* Renamed `StructSqlArgs -\u003e StructNamedArgs`.\n\nAlso moved some reflection-related utils to a [tiny dependency](https://github.com/mitranim/refut).\n\n### 0.1.1\n\nFirst tagged release. Added `SqlArgs` and `SqlQuery` for query building.\n\n## Contributing\n\nIssues and pull requests are welcome! The development setup is simple:\n\n```sh\ngit clone https://github.com/mitranim/gos\ncd gos\ngo test\n```\n\nTests currently require a local instance of Postgres on the default port. They create a separate \"database\", make no persistent changes, and drop it at the end.\n\n## License\n\nhttps://unlicense.org\n\n## Misc\n\nI'm receptive to suggestions. If this library _almost_ satisfies you but needs changes, open an issue or chat me up. Contacts: https://mitranim.com/#contacts\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitranim%2Fgos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitranim%2Fgos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitranim%2Fgos/lists"}