Skip to content

Commit c3f10a4

Browse files
committed
fix lint error
1 parent 1b7bf24 commit c3f10a4

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

backend/infrastructure/database/entity_queries.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"database/sql"
66
"fmt"
7+
"strings"
78

89
"github.com/google/uuid"
910
)
@@ -99,13 +100,13 @@ func SearchEntitiesByQuery(ctx context.Context, db DB, userID uuid.UUID, query s
99100
} else {
100101
// LIKE メタキャラクターをエスケープする
101102
// % -> \% , _ -> \_ , \ -> \\
102-
escapedQuery := ""
103+
var escapedQuery strings.Builder
103104
for _, r := range query {
104105
switch r {
105106
case '%', '_', '\\':
106-
escapedQuery += "\\" + string(r)
107+
escapedQuery.WriteString("\\" + string(r))
107108
default:
108-
escapedQuery += string(r)
109+
escapedQuery.WriteString(string(r))
109110
}
110111
}
111112

@@ -117,7 +118,7 @@ func SearchEntitiesByQuery(ctx context.Context, db DB, userID uuid.UUID, query s
117118
AND (e.name ILIKE $2 ESCAPE '\' OR ea.alias ILIKE $2 ESCAPE '\')
118119
ORDER BY e.name
119120
`
120-
rows, err = db.QueryContext(ctx, sqlstr, userID, "%"+escapedQuery+"%")
121+
rows, err = db.QueryContext(ctx, sqlstr, userID, "%"+escapedQuery.String()+"%")
121122
}
122123
if err != nil {
123124
return nil, fmt.Errorf("failed to search entities: %w", err)

backend/infrastructure/database/entity_queries_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,3 @@ func TestSearchEntitiesByQuery(t *testing.T) {
260260
}
261261
})
262262
}
263-

0 commit comments

Comments
 (0)