Conversation
…ation The postgres wrapper imports github.com/lib/pq which uses TLS and crypto APIs unavailable in tinygo's stdlib. Adding the !js build tag excludes the postgres wrapper when building for wasm targets. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a compilation failure for projects targeting WebAssembly (WASM) with TinyGo when using the Postgres database wrapper. By conditionally applying a build constraint, the Postgres-specific code, which relies on incompatible TLS and crypto APIs, is now correctly excluded from WASM builds, enhancing the tool's compatibility across different environments. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request aims to fix a tinygo/wasm compilation issue for the postgres wrapper by adding a //go:build !js build tag. The approach is correct, but the implementation in the Go template has a whitespace issue that makes the build tag invalid. I've provided a critical review comment with a code suggestion to fix the template logic, ensuring the build tag is generated correctly while maintaining clean formatting for all database engines.
| {{- if .Engine.IsPostgres}} | ||
| //go:build !js | ||
|
|
||
| {{end -}} |
There was a problem hiding this comment.
The whitespace control in this template block is incorrect. The {{- if on the first line will remove the preceding newline, causing the //go:build directive to be appended to the // Code generated by sqlc-multi-db. DO NOT EDIT. comment. This makes the build tag ineffective as it's no longer on its own line at the top of the file.
I've adjusted the template's whitespace handling to ensure the build tag is correctly placed on a new line and that there is a single blank line separating it from the package declaration, which is required by the Go toolchain. This fix also ensures that non-postgres generated files maintain clean formatting.
| {{- if .Engine.IsPostgres}} | |
| //go:build !js | |
| {{end -}} | |
| {{if .Engine.IsPostgres}} | |
| //go:build !js | |
| {{- end -}} |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9 +/- ##
=======================================
Coverage 28.83% 28.83%
=======================================
Files 6 6
Lines 697 697
=======================================
Hits 201 201
Misses 485 485
Partials 11 11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The postgres wrapper imports github.com/lib/pq which uses TLS and
crypto APIs unavailable in tinygo's stdlib. Adding the !js build tag
excludes the postgres wrapper when building for wasm targets.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com