Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ linters:
- bodyclose # checks whether HTTP response body is closed successfully
- durationcheck # check for two durations multiplied together
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- execinquery # execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds
- exhaustive # check exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- forbidigo # Forbids identifiers
Expand Down
13 changes: 2 additions & 11 deletions pkg/client/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,7 @@ func (c *Client) GetGroupMember(ctx context.Context, groupID, userID int64) (*Gr
args = append(args, userID)

sb := &strings.Builder{}
_, err := sb.WriteString(`SELECT "id", "userId", "groupId", "isAdmin" FROM user_groups WHERE "groupId"=$1 AND "userId"=$2`)
if err != nil {
return nil, err
}
_, err = sb.WriteString("LIMIT 1")
_, err := sb.WriteString(`SELECT "id", "userId", "groupId", "isAdmin" FROM user_groups WHERE "groupId"=$1 AND "userId"=$2 LIMIT 1`)
if err != nil {
return nil, err
}
Expand All @@ -309,13 +305,8 @@ func (c *Client) AddGroupMember(ctx context.Context, groupID, userID int64, isAd
l.Debug("add user to group", zap.Int64("user_id", userID))

args := []interface{}{groupID, userID, isAdmin}
sb := &strings.Builder{}
_, err := sb.WriteString(`INSERT INTO user_groups ("groupId", "userId", "isAdmin", "createdAt", "updatedAt") VALUES ($1, $2, $3, NOW(), NOW())`)
if err != nil {
return err
}

if _, err := c.db.Exec(ctx, sb.String(), args...); err != nil {
if _, err := c.db.Exec(ctx, `INSERT INTO user_groups ("groupId", "userId", "isAdmin", "createdAt", "updatedAt") VALUES ($1, $2, $3, NOW(), NOW())`, args...); err != nil {
return err
}

Expand Down
Loading