简体   繁体   English

如何定义适合Golang中任何函数的函数类型

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

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 键入funcType func(... interface {})... interface {},但失败

How can I do this? 我怎样才能做到这一点?

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. 您可以做的最好的事情是可以向其分配任何值(包括函数)的interface{}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM