-1
我一直在使用Golang的“testing”包编写测试用例。而且我遇到了必须将数组和函数指针写入表的情况。在struct(Golang)中写入数组
我尝试以下操作:
type myFunctionType func([]float64, []float64) float64
var testMatrix = []struct {
dataX []float64
dataY []float64
result float64
myFunction myFunctionType
} {
{ {2, 3}, {8, 7}, 1, doMagicOne},
{2, 3}, {8, 7}, 1, doMagicTwo},
}
但每次我最终得到时间的跟踪误差或别的东西:
missing type in composite literal
在上述任何输入?提前致谢。
Kenny,谢谢你的回答。我一直在尝试[]浮动({1,2}),并认为什么是错的! –