Skip to content

Commit

Permalink
creating a new slice in several job options because appending modifie…
Browse files Browse the repository at this point in the history
…s original
  • Loading branch information
JohnRoesler committed Dec 19, 2024
1 parent c180381 commit 7f6e385
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions job.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ type Weekdays func() []time.Weekday
// NewWeekdays provide the days of the week the job should run.
func NewWeekdays(weekday time.Weekday, weekdays ...time.Weekday) Weekdays {
return func() []time.Weekday {
weekdays = append(weekdays, weekday)
return weekdays
return append([]time.Weekday{weekday}, weekdays...)
}
}

Expand Down Expand Up @@ -400,8 +399,7 @@ type DaysOfTheMonth func() days
// -5 == 5 days before the end of the month.
func NewDaysOfTheMonth(day int, moreDays ...int) DaysOfTheMonth {
return func() days {
moreDays = append(moreDays, day)
return moreDays
return append([]int{day}, moreDays...)
}
}

Expand Down Expand Up @@ -439,8 +437,7 @@ type AtTimes func() []AtTime
// the job should be run
func NewAtTimes(atTime AtTime, atTimes ...AtTime) AtTimes {
return func() []AtTime {
atTimes = append(atTimes, atTime)
return atTimes
return append([]AtTime{atTime}, atTimes...)
}
}

Expand Down

0 comments on commit 7f6e385

Please sign in to comment.