Title: sqlc generates empty imports statement, e.g. "import ()" · Issue #3134 · sqlc-dev/sqlc · GitHub
Open Graph Title: sqlc generates empty imports statement, e.g. "import ()" · Issue #3134 · sqlc-dev/sqlc
X Title: sqlc generates empty imports statement, e.g. "import ()" · Issue #3134 · sqlc-dev/sqlc
Description: Version 1.25.0 What happened? When there are no imports to generate, sqlc generates two (2) unnecessary lines: import ()
Open Graph Description: Version 1.25.0 What happened? When there are no imports to generate, sqlc generates two (2) unnecessary lines: import ()
X Description: Version 1.25.0 What happened? When there are no imports to generate, sqlc generates two (2) unnecessary lines: import () <blank line> This is a problem when running this command in CI as gotf...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/3134
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sqlc generates empty imports statement, e.g. \"import ()\"","articleBody":"### Version\r\n\r\n1.25.0\r\n\r\n### What happened?\r\n\r\nWhen there are no imports to generate, `sqlc` generates two (2) unnecessary lines:\r\n\r\n```go\r\nimport ()\r\n\u003cblank line\u003e\r\n```\r\nThis is a problem when running this command in CI as `gotfmt` will remove that empty import and the blank line that follows:\r\n\r\n```shell\r\ngofmt -s -w . \u0026\u0026 git diff --exit-code\r\n```\r\n\r\nThis is a simple fix; add a `hasImports` method for use by the template and then wrap every place in templates that generate imports with `{{ if hasImports .SourceName }}`. After submitting this issue I will submit a PR to fix this issue.\r\n\r\nSee `db/models.go` [in playground](https://play.sqlc.dev/p/d03273b7d19072abdcb608fc72f577628aad25c2e478f7709a07221438da2832).\r\n\r\n### Relevant log output\r\n\r\n```shell\r\nn/a\r\n```\r\n\r\n\r\n### Database schema\r\n\r\n```sql\r\nn/a\r\n```\r\n\r\n\r\n### SQL queries\r\n\r\n```sql\r\nn/a\r\n```\r\n\r\n\r\n### Configuration\r\n\r\n```yaml\r\nn/a\r\n```\r\n\r\n\r\n### Playground URL\r\n\r\nhttps://play.sqlc.dev/p/d03273b7d19072abdcb608fc72f577628aad25c2e478f7709a07221438da2832\r\n\r\n### What operating system are you using?\r\n\r\nmacOS\r\n\r\n### What database engines are you using?\r\n\r\nSQLite\r\n\r\n### What type of code are you generating?\r\n\r\nGo","author":{"url":"https://github.com/mikeschinkel","@type":"Person","name":"mikeschinkel"},"datePublished":"2024-01-14T19:59:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/3134/sqlc/issues/3134"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6d7a61e7-6c7e-de35-4bc3-e236e9476f47 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 924E:DC47A:18B2C92:231AA67:6A50C45B |
| html-safe-nonce | 83f32c8debe028776b60a962bd6d41278efc8d8ca06d797dd200134076336387 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjRFOkRDNDdBOjE4QjJDOTI6MjMxQUE2Nzo2QTUwQzQ1QiIsInZpc2l0b3JfaWQiOiIyMTEyODcyODE5MDM3NjE5MjkxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 35340e5443cec018c52e67dfc3788be1510061de7453e209b6d5de72f80f1302 |
| hovercard-subject-tag | issue:2080876107 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sqlc-dev/sqlc/3134/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cb8740fc4f0869b37e616078362625b830b6c3e44cc7acf68156ddd93436865a/sqlc-dev/sqlc/issues/3134 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cb8740fc4f0869b37e616078362625b830b6c3e44cc7acf68156ddd93436865a/sqlc-dev/sqlc/issues/3134 |
| og:image:alt | Version 1.25.0 What happened? When there are no imports to generate, sqlc generates two (2) unnecessary lines: import () |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mikeschinkel |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72b13e0e8d0319acdd27a145cfe73f4f06c791713d0ac4690e41fb68ad28cac0 |
| turbo-cache-control | no-preview |
| go-import | github.com/sqlc-dev/sqlc git https://github.com/sqlc-dev/sqlc.git |
| octolytics-dimension-user_id | 136738596 |
| octolytics-dimension-user_login | sqlc-dev |
| octolytics-dimension-repository_id | 193160679 |
| octolytics-dimension-repository_nwo | sqlc-dev/sqlc |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 193160679 |
| octolytics-dimension-repository_network_root_nwo | sqlc-dev/sqlc |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 08e79d53fc070870d5b168356afebb1e286a2ffe |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width