Fix concurrency safety, panic prevention, and weekday range bug#7
Merged
Merged
Conversation
5 tasks
…ckage - Add thread-safe Get/SetWeekStartDay() functions to fix data race on global WeekStartDay - Add helper methods (getWeekStartDay, getTimeFormats, getTimeLocation) for nil-safe access - Update BeginningOfWeek to use nil-safe helper methods - Fix GetWeekdaysInRange incorrect logic that skipped weekdays in leap/non-leap years - Add safe weekday methods (*Safe variants) that return errors instead of panicking - Improve error messages with package prefix and proper quoting - Add comprehensive tests for all fixes including concurrency tests Agent-Logs-Url: https://github.com/sivaosorg/timefy/sessions/0772df36-2c23-49e6-a98c-f8ff5a636e5c Co-authored-by: pnguyen215 <39581473+pnguyen215@users.noreply.github.com>
- Extract weekdaySafe helper function to reduce code duplication in *Safe methods - Improve documentation for deprecated WeekStartDay variable clarifying race condition - Fix test assertions to match actual weekday calculation behavior - Add comprehensive validation of month and day in test cases Agent-Logs-Url: https://github.com/sivaosorg/timefy/sessions/0772df36-2c23-49e6-a98c-f8ff5a636e5c Co-authored-by: pnguyen215 <39581473+pnguyen215@users.noreply.github.com>
- Add guidance to error message for missing time formats - Update SundaySafe documentation to accurately describe upcoming Sunday behavior Agent-Logs-Url: https://github.com/sivaosorg/timefy/sessions/0772df36-2c23-49e6-a98c-f8ff5a636e5c Co-authored-by: pnguyen215 <39581473+pnguyen215@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Perform comprehensive Go code review for timefy
Fix concurrency safety, panic prevention, and weekday range bug
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comprehensive audit identified data races, panic-prone APIs, and incorrect weekday filtering logic.
Concurrency Safety
GetWeekStartDay()/SetWeekStartDay()withsync.RWMutexprotectionWeekStartDayglobal (retained for backward compatibility)Panic Prevention
*Safevariants for all weekday methods (MondaySafe,TuesdaySafe, etc.) that return errors instead of panickingweekdaySafe()helper to reduce duplicationNil Safety
getWeekStartDay(),getTimeFormats(),getTimeLocation()helpers for nil-safeRuleaccess inTimexBug Fix
GetWeekdaysInRange()which had broken leap year logic that skipped valid weekdaysUsage