-
Notifications
You must be signed in to change notification settings - Fork 2
fix: resolve golangci-lint errors #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,7 +58,7 @@ | |
| if err != nil { | ||
| // Log failed login attempt | ||
| s.logAudit(nil, req.Username, models.ActionLoginFailed, models.ResourceAuth, | ||
| fmt.Sprintf("Login failed: user not found"), ipAddress, userAgent, false) | ||
| return nil, fmt.Errorf("invalid credentials") | ||
| } | ||
|
|
||
|
|
@@ -66,14 +66,14 @@ | |
| if err := s.userRepo.CheckPassword(user.Password, req.Password); err != nil { | ||
| // Log failed login attempt | ||
| s.logAudit(&user.ID, user.Username, models.ActionLoginFailed, models.ResourceAuth, | ||
| fmt.Sprintf("Login failed: invalid password"), ipAddress, userAgent, false) | ||
| return nil, fmt.Errorf("invalid credentials") | ||
| } | ||
|
|
||
| // Check if user is active | ||
| if !user.IsActive { | ||
| s.logAudit(&user.ID, user.Username, models.ActionLoginFailed, models.ResourceAuth, | ||
| fmt.Sprintf("Login failed: account deactivated"), ipAddress, userAgent, false) | ||
| return nil, fmt.Errorf("account is deactivated") | ||
| } | ||
|
|
||
|
|
@@ -93,7 +93,7 @@ | |
|
|
||
| // Log successful login | ||
| s.logAudit(&user.ID, user.Username, models.ActionLogin, models.ResourceAuth, | ||
| fmt.Sprintf("User logged in successfully"), ipAddress, userAgent, true) | ||
| "User logged in successfully", ipAddress, userAgent, true) | ||
|
Comment on lines
94
to
+96
|
||
|
|
||
| return authResponse, nil | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,7 +171,17 @@ func (s *holidayService) GetUpcomingHolidays(limit int) ([]models.Holiday, error | |
| today := time.Now() | ||
| endDate := today.AddDate(1, 0, 0) // Next year | ||
|
|
||
| return s.repo.GetByDateRange(today, endDate, nil) | ||
| holidays, err := s.repo.GetByDateRange(today, endDate, nil) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Apply limit | ||
| if len(holidays) > limit { | ||
| holidays = holidays[:limit] | ||
| } | ||
|
Comment on lines
+174
to
+182
|
||
|
|
||
| return holidays, nil | ||
|
Comment on lines
+179
to
+184
|
||
| } | ||
|
|
||
| // GetHolidaysByYear gets holidays by specific year | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING: Performance issue - The mutex lock (
rl.mu.Lock()) is now held during the entire iteration over all visitors (lines 57-63). This can cause significant blocking of other goroutines that need to check/update rate limits.Previous code acquired the lock inside the
selectblock for each tick, but still held it during iteration. The current simplification usingfor range ticker.Cdoesn't change the locking behavior, but the code is now clearer. However, consider copying the map keys first, then releasing the lock before processing:This allows other operations to proceed while cleanup is happening.