I have a scenario where I'm calling a function leveraging a common background worker thread that has arguments as func somefunction(data ...interface{}) to be generic and reusable across the application.
In one of the functions, the number of arguments are more and in the unction definition, I am casting the array items individually like
someVar := data[0].(string)
Now this approach is fine when I'm usually dealing with 1-2 arguments. But it becomes tedious when the number of arguments increases.
So is there a cleaner way to parse the elements into a struct in the order of their appearance?
My objective is to do this in a cleaner way rather than individually getting one from array and casting to a string variable.
Sample code explaining the scenario https://go.dev/play/p/OScAjyyLW0W