{"id":13434621,"url":"https://github.com/sqlc-dev/sqlc-gen-go","last_synced_at":"2025-04-06T07:09:52.138Z","repository":{"id":205186196,"uuid":"713526469","full_name":"sqlc-dev/sqlc-gen-go","owner":"sqlc-dev","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-20T18:43:06.000Z","size":42,"stargazers_count":87,"open_issues_count":1,"forks_count":37,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-30T06:03:55.657Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":false,"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/sqlc-dev.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}},"created_at":"2023-11-02T17:42:50.000Z","updated_at":"2025-03-28T12:17:31.000Z","dependencies_parsed_at":"2024-01-04T02:25:32.215Z","dependency_job_id":"e35a0526-1fb1-4458-b111-4648541a9cd6","html_url":"https://github.com/sqlc-dev/sqlc-gen-go","commit_stats":null,"previous_names":["sqlc-dev/sqlc-gen-go"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-dev%2Fsqlc-gen-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-dev%2Fsqlc-gen-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-dev%2Fsqlc-gen-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-dev%2Fsqlc-gen-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqlc-dev","download_url":"https://codeload.github.com/sqlc-dev/sqlc-gen-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445667,"owners_count":20939958,"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":[],"created_at":"2024-07-31T03:00:19.068Z","updated_at":"2025-04-06T07:09:52.115Z","avatar_url":"https://github.com/sqlc-dev.png","language":"Go","funding_links":[],"categories":["Supported languages"],"sub_categories":[],"readme":"# sqlc-gen-go\n\n\u003e [!IMPORTANT]  \n\u003e This repository is read-only. It contains a working Go codegen plugin extracted from https://github.com/sqlc-dev/sqlc which you can fork and modify to meet your needs.\n\nSee [Building from source](#building-from-source) and [Migrating from sqlc's built-in Go codegen](#migrating-from-sqlcs-built-in-go-codegen) if you want to use a modified fork in your project.\n\n## Usage\n\n```yaml\nversion: '2'\nplugins:\n- name: golang\n  wasm:\n    url: https://downloads.sqlc.dev/plugin/sqlc-gen-go_1.5.0.wasm\n    sha256: 4ca52949f4dc04b55188439f5de0ae20af2a71e3534b87907f2a7f466bda59ec\nsql:\n- schema: schema.sql\n  queries: query.sql\n  engine: postgresql\n  codegen:\n  - plugin: golang\n    out: db\n    options:\n      package: db\n      sql_package: pgx/v5\n```\n\n## Building from source\n\nAssuming you have the Go toolchain set up, from the project root you can simply `make all`.\n\n```sh\nmake all\n```\n\nThis will produce a standalone binary and a WASM blob in the `bin` directory.\nThey don't depend on each other, they're just two different plugin styles. You can\nuse either with sqlc, but we recommend WASM and all of the configuration examples\nhere assume you're using a WASM plugin.\n\nTo use a local WASM build with sqlc, just update your configuration with a `file://`\nURL pointing at the WASM blob in your `bin` directory:\n\n```yaml\nplugins:\n- name: golang\n  wasm:\n    url: file:///path/to/bin/sqlc-gen-go.wasm\n    sha256: \"\"\n```\n\nAs-of sqlc v1.24.0 the `sha256` is optional, but without it sqlc won't cache your\nmodule internally which will impact performance.\n\n## Migrating from sqlc's built-in Go codegen\n\nWe’ve worked hard to make switching to sqlc-gen-go as seamless as possible. Let’s say you’re generating Go code today using a sqlc.yaml configuration that looks something like this:\n\n```yaml\nversion: 2\nsql:\n- schema: \"query.sql\"\n  queries: \"query.sql\"\n  engine: \"postgresql\"\n  gen:\n    go:\n      package: \"db\"\n      out: \"db\"\n      emit_json_tags: true\n      emit_pointers_for_null_types: true\n      query_parameter_limit: 5\n      overrides:\n      - column: \"authors.id\"\n        go_type: \"your/package.SomeType\"\n      rename:\n        foo: \"bar\"\n```\n\nTo use the sqlc-gen-go WASM plugin for Go codegen, your config will instead look something like this:\n\n```yaml\nversion: 2\nplugins:\n- name: golang\n  wasm:\n    url: https://downloads.sqlc.dev/plugin/sqlc-gen-go_1.3.0.wasm\n    sha256: e8206081686f95b461daf91a307e108a761526c6768d6f3eca9781b0726b7ec8\nsql:\n- schema: \"query.sql\"\n  queries: \"query.sql\"\n  engine: \"postgresql\"\n  codegen:\n  - plugin: golang\n    out: \"db\"\n    options:\n      package: \"db\"\n      emit_json_tags: true\n      emit_pointers_for_null_types: true\n      query_parameter_limit: 5\n      overrides:\n      - column: \"authors.id\"\n        go_type: \"your/package.SomeType\"\n      rename:\n        foo: \"bar\"\n```\n\nThe differences are:\n* An additional top-level `plugins` list with an entry for the Go codegen WASM plugin. If you’ve built the plugin from source you’ll want to use a `file://` URL. The `sha256` field is required, but will be optional in the upcoming sqlc v1.24.0 release.\n* Within the `sql` block, rather than `gen` with `go` nested beneath you’ll have a `codegen` list with an entry referencing the plugin name from the top-level `plugins` list. All options from the current `go` configuration block move as-is into the `options` block within `codegen`. The only special case is `out`, which moves up a level into the `codegen` configuration itself.\n\n### Global overrides and renames\n\nIf you have global overrides or renames configured, you’ll need to move those to the new top-level `options` field. Replace the existing `go` field name with the name you gave your plugin in the `plugins` list. We’ve used `\"golang\"` in this example.\n\nIf your existing configuration looks like this:\n\n```yaml\nversion: \"2\"\noverrides:\n  go:\n    rename:\n      id: \"Identifier\"\n    overrides:\n    - db_type: \"timestamptz\"\n      nullable: true\n      engine: \"postgresql\"\n      go_type:\n        import: \"gopkg.in/guregu/null.v4\"\n        package: \"null\"\n        type: \"Time\"\n...\n```\n\nThen your updated configuration would look something like this:\n\n```yaml\nversion: \"2\"\nplugins:\n- name: golang\n  wasm:\n    url: https://downloads.sqlc.dev/plugin/sqlc-gen-go_1.3.0.wasm\n    sha256: e8206081686f95b461daf91a307e108a761526c6768d6f3eca9781b0726b7ec8\noptions:\n  golang:\n    rename:\n      id: \"Identifier\"\n    overrides:\n    - db_type: \"timestamptz\"\n      nullable: true\n      engine: \"postgresql\"\n      go_type:\n        import: \"gopkg.in/guregu/null.v4\"\n        package: \"null\"\n        type: \"Time\"\n...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlc-dev%2Fsqlc-gen-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqlc-dev%2Fsqlc-gen-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlc-dev%2Fsqlc-gen-go/lists"}