Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I define a function type adapted to any function in golang

Tags:

go

I just want to define a function type which will match all functions and I have tried this:

type funcType func(...interface{}) ...interface{} but failed

How can I do this?

like image 944
Aaron Avatar asked Sep 02 '25 02:09

Aaron


1 Answers

There is no function type that's compatible with any function.

The best you can do is interface{} to which any value is assignable to, including functions.

like image 81
Paul Hankin Avatar answered Sep 07 '25 21:09

Paul Hankin