jasonlvhit / gocron

A Golang Job Scheduling Package.
BSD 2-Clause "Simplified" License
3.47k stars 345 forks source link

gocron.Every(5).Minute().Do(func () {}) panics with no clear error #4

Open marksalpeter opened 9 years ago

marksalpeter commented 9 years ago

gocron.Every(5).Minute().Do(func () {}) panics with no error message, its literally an empty string. this should be equivalent to gocron.Every(5).Minutes().Do(func () {})

Dennis-Kluge commented 9 years ago

I ran into the same issue. A little hint would be pretty helpful.

I would fix the messages if we could agree on an useful text like:

"Use Minutes() if you want to schedule intervals > 1min "

The same issue applies to Hour() and Second().

Claudiu commented 9 years ago

:+1: to gocron.Every(5).Minute().Do(func () {}) being an alias of gocron.Every(5).Minutes().Do(func () {}).

Dennis-Kluge commented 9 years ago

If aliasing is an option I would additionally print a message that the function is misused.

marksalpeter commented 8 years ago

@HorstMumpitz I don't think it is being misused. If you look at the standard libraries time package every duration is defined in the singular. For example, Its common for example to do something like

fiveMinutes := 5 * time.Minute

It might make sense to remove the plurals. Any thoughts?

fredleger commented 7 years ago

one thing here is that if you want to pass the number of minutes as an arg of your program you have to do something like :

switch argv[0] {
case 1: gocron.Every(argv[0]).Minute().Do(func () {})
default: gocron.Every(5).Minute*s*().Do(func () {})
}

Which is not very usefull.

as i like to keep my code as readable as possible, i would vote also at least for a clear warning about that missuse or an alias that make it work the nice way :-)

MovieStoreGuy commented 7 years ago

Why not just deprecate the singular and just use the plural?

gocron.Every(1).Minutes().Do(func(){})

Is still readable.