I don't know how to use an interface as a parameter for a function, I keep getting a syntax error:
syntax error: unexpected comma, expecting {
But it looks the same as any other function:
func getWall(array [][]interface, wallSize float64){
var currentWall, highWallPrice float64 = 0, 0;
err := false
i := 0
for highWall < wallSize {
if i >= (len(array)) {
fmt.Println("Not enough offers for pair " + pair)
currentWall = wallSize
err = true
}else{
price = getFloat(array[i][0].(string))
amount = getFloat(array[i][1].(string))
currentWall = currentWall + price * amount
i++
}
}
if !fail {
wallPrice = getFloat(array[i][0].(string))
}
return wallPrice, err
}
I'm starting to learn golang any help is appreciated.