// SameArray checks if two slices reference the same backing array.funcSameArray[Tany](s1,s2[]T)bool{cap1:=cap(s1)cap2:=cap(s2)// nil slices will never have the same array.ifcap1==0||cap2==0{returnfalse}// compare the address of the last element in each backing array.return&s1[0:cap1][cap1-1]==&s2[0:cap2][cap2-1]}