mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
574 B
30 lines
574 B
package compare
|
|
|
|
import "v2ray.com/core/common/errors"
|
|
|
|
func BytesEqualWithDetail(a []byte, b []byte) error {
|
|
if len(a) != len(b) {
|
|
return errors.New("mismatch array length ", len(a), " vs ", len(b))
|
|
}
|
|
for idx, v := range a {
|
|
if b[idx] != v {
|
|
return errors.New("mismatch array value at index [", idx, "]: ", v, " vs ", b[idx])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func BytesEqual(a []byte, b []byte) bool {
|
|
return BytesEqualWithDetail(a, b) == nil
|
|
}
|
|
|
|
func BytesAll(arr []byte, value byte) bool {
|
|
for _, v := range arr {
|
|
if v != value {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|