go-gorm / go-gorm/cli

style: rename `_params` and `sb` in generated code to clearer names

Open
#52 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
108
Forks
15
PR merge metrics
No merged PRs in 30d

Description

## Summary

The SQL template renderer generates two local variables in every method body:

```go
var sb strings.Builder
_params := make([]any, 0, N)
```

Two issues:

1. **`_params`** — The leading `_` is the Go blank identifier. Using it as a prefix for an actively-used variable is misleading. It suggests the variable is discarded when it's actually central to the method.
2. **`sb`** — Too terse for a variable used across 20+ lines. A builder for a SQL query string deserves a clearer name.

## Proposed

```go
var buf strings.Builder
params := make([]any, 0, N)
```

Or alternatively `query` instead of `buf` since it's building a SQL query string.

## Root Cause

- `internal/gen/sqlparser.go` — `RenderSQLTemplate` emits `var sb strings.Builder` and `_params := make(...)` literally
- Also referenced in `internal/gen/template.go` method body templates

## Affected

All generated output. The hardcoded names in the SQL template renderer need updating, plus any test golden files that match these strings.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.