I just started using Go, and one thing that makes me nervous is that if I define a function that accepts an array, and then pass an array to a function with a specific size, VS Code complains about it.
For example, I have something like this:
func cmplt(a, b []uint64) uint64 {
var r, m, i uint64
r = 0
m = 0
for i = 2; i >= 0; i-- {
r |= LtUint64(a[i], b[i]) & ^m
m |= MaskUint64(NeUint64(a[i], b[i]))
}
return r & 1
}
And then I call this function inside another function as:
func singleSample(in []uint64) uint64 {
var i, index uint64
index = 0
for i = 0; i < 52; i++ {
index = SelectUint64(index, i+1, cmplt(in, table[i]))
}
return index
}
where table
has type [52][3]uint64
. I get an error message saying: cannot use table (type [3]uint64) as []uint64 in argument to cmplt
.
Is there any way in Go to workaround this, instead of specifically specifying the array size in function parameter?