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
4 changes: 4 additions & 0 deletions generator/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ var (
`

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

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

Choose a reason for hiding this comment

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

critical

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.

Suggested change
{{- if .Engine.IsPostgres}}
//go:build !js
{{end -}}
{{if .Engine.IsPostgres}}
//go:build !js
{{- end -}}

package {{.PackageName}}

import (
Expand Down
Loading