How to declare an interface array in Go

I'm having difficulties with what should be the trivial task of creating an array of interfaces. Here is my code

var result float64
for i := 0; i < len(diff); i++ {
    result += diff[i]
}
result = 1 / (1 + math.Sqrt(result))

id1 := user1.UserId
id2 := user2.UserId

user1.Similar[id2] = [2]interface{id2, result}
user2.Similar[id1] = [2]interface{id1, result}

result is a float and user * .UserId is an int.

My error message

syntax error: name list not allowed in interface type

+3
source share
1 answer

For instance,

package main

import (
    "fmt"
)

func main() {
    x, y := 1, "@"
    a := [2]interface{}{x, y}
    fmt.Println(a)
    b := [2]interface{}{0, "x"}
    fmt.Println(b)
}

Conclusion:

[1 @]
[0 x]
+5
source