Posted on 24th April 2024
You can use compare() function to compare two slices in Golang here the example
package main
import (
"bytes"
"fmt"
)
func main() {
1slice := []byte{'M', 'I', 'N', 'D'}
2slice := []byte{'M', 'E', 'N', 'D'}
res := bytes.Compare(1slice, 2slice)
if res == 0 {
fmt.Println("both the slices are equal")
} else {
fmt.Println("both the slices are not equal")
}
}
Output:
both the slices are not equal
STILL GOT QUERIES?