Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions generator/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ var (
const wrapperTemplate = `// Code generated by sqlc-multi-db. DO NOT EDIT.
{{if .Engine.IsPostgres}}
//go:build !js

{{- end -}}
{{- end}}
Comment on lines 57 to +59

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While your change is an improvement over the original code, it still results in output that is missing a blank line in some cases, relying on gofumpt to fix the formatting. A slightly different approach can produce correctly formatted output directly from the template for both cases (when the if is true or false). This improves the template's clarity and robustness.

Consider this alternative structure:

const wrapperTemplate = `// Code generated by sqlc-multi-db. DO NOT EDIT.
{{if .Engine.IsPostgres}}
//go:build !js

{{end -}}
package {{.PackageName}}
...
`

This would correctly handle newlines for both branches of the if statement, producing well-formatted code directly.

package {{.PackageName}}

import (
Expand Down
Loading