go-gorm / go-gorm/cli

fix: typo `sql tempalte` and minor style issues in `internal/gen`

Open
#51 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

A few small issues in `internal/gen/`:

### 1. Typo in panic message

`internal/gen/sqlparser.go:90`:
```go
panic(fmt.Sprintf("unsupported func %q in sql tempalte\n", f.Name))
```
`tempalte` → `template`

### 2. Abbreviated variable name `pth`

`internal/gen/generator.go:110`:
```go
for pth, file := range g.Files {
```
`pth` is an abbreviation that saves 1 character over `path`. In a 30-line block it adds no value. Use `path` or `filePath` for readability.

### 3. Operator precedence ambiguity

`internal/gen/generator.go:630`:
```go
if method.SQL.Where == "" && method.SQL.Select == "" || method.SQL.Raw != "" {
```
The `||` binds loosely. Add explicit parens to make intent clear:
```go
if (method.SQL.Where == "" && method.SQL.Select == "") || method.SQL.Raw != "" {
```

### 4. Verbose local in `sqlparser.go`

`internal/gen/sqlparser.go:326-343`:
```go
paramsCount := 0 // used in 4 adjacent lines
codes := []string{} // used in 4 adjacent lines
```
Shorter names like `count` and `lines` would suffice for the narrow scope.

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.