You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my attempts to parse a gocron.AtTimes back to a time.Time I discovered a strange behavior.
My current attempts consists of this part of the function, that takes the gocron.AtTimes and converts it back formated time Strings:
When I execute this function multiple times with the same input atTimes then the atTimes seems to be modified and appended by the first entry each time.
These are the logger prints after each execution:
The original atTimes was only 9:30 and 9:59, therefore I expect only [9:30 9:59] as a return.
To Reproduce
Steps to reproduce the behavior:
Create a gocron.AtTimes instance with two AtTime values, e.g., 9:30and 9:59.
Call the reverseParseTimes function with the created gocron.AtTimes instance.
Log the output of the reverseParseTimes function.
Repeat step 2 and 3 multiple times.
Version
I used v2.14.0
Expected behavior
I expect the reverseParseTimes function to consistently return the same parsed times without appending duplicate entries. Specifically, the expected output should be [9:30 9:59] for each execution.
Additional context
I tried to look a bit into where the problem might be and discovered that changing the NewAtTimes function seems to fix my issue (although I am not sure if it creates other bugs, it was just a crude attempt).
Original NewAtTimes function:
This was a fix proposed by Copilot so I would not trust it completely and I am not entirely sure what is different in the modified function.
But I think the original function seems to modify the original atTimes slice by appending atTime to it each time the function is called. The second implementation creates a new slice each time, therefore preserving the original atTimes slice?
I observe the expected behavior with the modified NewAtTimes function:
Describe the bug
In my attempts to parse a gocron.AtTimes back to a time.Time I discovered a strange behavior.
My current attempts consists of this part of the function, that takes the gocron.AtTimes and converts it back formated time Strings:
When I execute this function multiple times with the same input atTimes then the atTimes seems to be modified and appended by the first entry each time.
These are the logger prints after each execution:
The original atTimes was only 9:30 and 9:59, therefore I expect only
[9:30 9:59]
as a return.To Reproduce
Steps to reproduce the behavior:
gocron.AtTimes
instance with twoAtTime
values, e.g.,9:30
and9:59
.reverseParseTimes
function with the createdgocron.AtTimes
instance.reverseParseTimes
function.Version
I used
v2.14.0
Expected behavior
I expect the
reverseParseTimes
function to consistently return the same parsed times without appending duplicate entries. Specifically, the expected output should be[9:30 9:59]
for each execution.Additional context
I tried to look a bit into where the problem might be and discovered that changing the NewAtTimes function seems to fix my issue (although I am not sure if it creates other bugs, it was just a crude attempt).
Original
NewAtTimes
function:Modified
NewAtTimes
function:This was a fix proposed by Copilot so I would not trust it completely and I am not entirely sure what is different in the modified function.
But I think the original function seems to modify the original atTimes slice by appending atTime to it each time the function is called. The second implementation creates a new slice each time, therefore preserving the original atTimes slice?
I observe the expected behavior with the modified
NewAtTimes
function:The text was updated successfully, but these errors were encountered: