Skip to content

Commit 90d592c

Browse files
dorothyyzhclaude
andcommitted
fix(lint): fix errcheck and staticcheck issues
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2058c94 commit 90d592c

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

ratelimiter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestMain(m *testing.M) {
5252
redisCli = redis.NewClient(&redis.Options{
5353
Addr: strings.TrimPrefix(endpoint, "redis://"),
5454
})
55-
defer redisCli.Close()
55+
defer func() { _ = redisCli.Close() }()
5656

5757
// Create SQL rate limiter and migrate table
5858
sqlLimiter, err := sqlrl.New(db, "kvs")

redisrl/redis_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestMain(m *testing.M) {
3434
redisClient = redis.NewClient(&redis.Options{
3535
Addr: strings.TrimPrefix(endpoint, "redis://"),
3636
})
37-
defer redisClient.Close()
37+
defer func() { _ = redisClient.Close() }()
3838

3939
m.Run()
4040
}

sqlrl/sql.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ func New(db *gorm.DB, tableName string) (*RateLimiter, error) {
5353
// Build raw query based on database type
5454
// Prioritize real-time accuracy for precise rate limiting
5555
var currentTimestampQuery string
56-
switch db.Dialector.Name() {
56+
switch db.Name() {
5757
case "mysql":
5858
currentTimestampQuery = "SYSDATE(6)" // MySQL: real-time timestamp with microsecond precision
5959
case "postgres":
6060
currentTimestampQuery = "clock_timestamp()" // PostgreSQL: real-time timestamp for maximum accuracy
6161
default:
62-
return nil, errors.Errorf("unsupported dialect %q, must be mysql or postgres", db.Dialector.Name())
62+
return nil, errors.Errorf("unsupported dialect %q, must be mysql or postgres", db.Name())
6363
}
6464

6565
s.selectQuery = fmt.Sprintf(`

0 commit comments

Comments
 (0)