So I want to be able to pass a matrix as a function in an argument in Golang. It could be a different size each time - e.g., a 4x4 matrix, 3x2 matrix, etc. If I try running the test code below against the source code I get an error message like:
How do I pass a 2 dimensional array into a function? I'm new to Go and come from a dynamic language background (Python, Ruby).
cannot use mat[:][:] (type [][3]int) as type [][]int in argument to zeroReplaceMatrix
source code
func ReplaceMatrix(mat [][]int, rows, cols, a, b int) {
}
test code
func TestReplaceMatrix(t *testing.T) {
var mat [3][3]int
//some code
got := ReplaceMatrix(mat[:][:], 3, 3, 0, 1)
}