Skip to content

Commit 4e8e832

Browse files
Fix GoSec G104 linting errors
- Explicitly ignore errors for NewBufferString since they can't return an error - Handle uncaught errors correctly
1 parent bbc850a commit 4e8e832

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

driver/inmemory/internal/generate_matcher/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"flag"
5+
"fmt"
56
"os"
67
"path/filepath"
78
"reflect"
@@ -200,7 +201,11 @@ func main() {
200201
if err != nil {
201202
panic(err)
202203
}
203-
defer f.Close()
204+
defer func() {
205+
if err := f.Close(); err != nil {
206+
fmt.Printf("failed to close file: %s\n", err)
207+
}
208+
}()
204209

205210
err = tmpl.Execute(f, struct {
206211
Types []reflect.Kind

driver/inmemory/matcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ func (c *metadataConstraint) Matches(val interface{}) (bool, error) {
119119
func (e IncompatibleMatcherError) Error() string {
120120
msg := bytes.NewBufferString("goengine: incompatible metadata.Matcher")
121121
for _, err := range e {
122-
msg.WriteRune('\n')
123-
msg.WriteString(err.Error())
122+
_, _ = msg.WriteRune('\n')
123+
_, _ = msg.WriteString(err.Error())
124124
}
125125

126126
return msg.String()

driver/sql/postgres/eventstore.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,17 +254,17 @@ func (e *EventStore) prepareInsertValues(streamEvents []goengine.Message, lenCol
254254
for i := 0; i < placeholderCount; i++ {
255255
if m := i % lenCols; m == 0 {
256256
if i != 0 {
257-
placeholders.WriteString("),")
257+
_, _ = placeholders.WriteString("),")
258258
}
259-
placeholders.WriteRune('(')
259+
_, _ = placeholders.WriteRune('(')
260260
} else {
261-
placeholders.WriteRune(',')
261+
_, _ = placeholders.WriteRune(',')
262262
}
263263

264-
placeholders.WriteRune('$')
265-
placeholders.WriteString(strconv.Itoa(i + 1))
264+
_, _ = placeholders.WriteRune('$')
265+
_, _ = placeholders.WriteString(strconv.Itoa(i + 1))
266266
}
267-
placeholders.WriteString(")")
267+
_, _ = placeholders.WriteString(")")
268268
e.preparedInsertPlaceholder[messageCount] = placeholders.String()
269269

270270
return e.preparedInsertPlaceholder[messageCount]

test/internal/postgres.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (c *dbController) disableDatabaseAccess(t *testing.T, databaseName string)
8282
// Terminate existing connections
8383
rows, err := c.db.Query("SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = $1", databaseName)
8484
require.NoError(t, err)
85-
defer rows.Close()
85+
require.NoError(t, err, rows.Close())
8686
}
8787

8888
func (c *dbController) enableDatabaseAccess(t *testing.T, databaseName string) {

0 commit comments

Comments
 (0)