I wrote a code and want to check the equality of two slices like:
package main
import (
"fmt"
)
func main() {
s := []int{1, 2, 3}
s2 := []int{1, 2, 3}
fmt.Println(s == s2)
}
When I run this sample code to compare two slices it panics with error slice can only be compared to nil
. I searched and found (Equality (Identity) of Go Slices) that I need to do the comparison myself but what is the underlying reason(s) that comparison is not available for the slice type like the one we have for arrays?