Skip to content
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

[BUG] - Cannot create job with task with variadic args #677

Open
bbompk opened this issue Feb 23, 2024 · 2 comments
Open

[BUG] - Cannot create job with task with variadic args #677

bbompk opened this issue Feb 23, 2024 · 2 comments
Labels
bug Something isn't working v2

Comments

@bbompk
Copy link

bbompk commented Feb 23, 2024

Describe the bug

When creating a job with a task that has variadic args, the validator in the library will expect the variadic args to be "1" argument (suspect to be a slice of that type). So creating a job with a task that has function of variadic arguments will always return ErrNewJobWrongNumberOfParameters.

To Reproduce

Steps to reproduce the behavior:

  1. Create a function that has variadic args
  2. Try create a cronjob from that
scheduler, _ := gocron.NewScheduler()

myfunc := func(args ...string) {
  panic("This works")
}

// will have error
job, err := scheduler.NewJob(
  gocron.CronJob("* * * * 1", false),
  gocron.NewTask(myfunc), // the validator will expect num param to be 1 (slice of string)
)

Version

v2.2.1

Expected behavior

should be able to execute task with variadic parameters.

Additional context

@bbompk bbompk added the bug Something isn't working label Feb 23, 2024
@bbompk
Copy link
Author

bbompk commented Feb 23, 2024

Well I guess I should use slice as an argument instead of variadic args..

@JohnRoesler
Copy link
Contributor

That's an option. But may be a way to handle variadic args.

@JohnRoesler JohnRoesler added the v2 label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2
Projects
None yet
Development

No branches or pull requests

2 participants