MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / valueEqual

Method valueEqual

structure/list.go:543–571  ·  view source on GitHub ↗

valueEqual checks if two values are equal. It supports comparing string, int, float64, bool, and []byte values.

(value1 interface{}, value2 interface{})

Source from the content-addressed store, hash-verified

541// valueEqual checks if two values are equal.
542// It supports comparing string, int, float64, bool, and []byte values.
543func (l *ListStructure) valueEqual(value1 interface{}, value2 interface{}) bool {
544 type1 := reflect.TypeOf(value1)
545 type2 := reflect.TypeOf(value2)
546
547 // If the types are not the same, the values are not equal
548 if type1 != type2 {
549 return false
550 }
551
552 // Compare based on type
553 switch type1.Kind() {
554 case reflect.String:
555 return value1.(string) == value2.(string)
556 case reflect.Int:
557 return value1.(int) == value2.(int)
558 case reflect.Float64:
559 return value1.(float64) == value2.(float64)
560 case reflect.Bool:
561 return value1.(bool) == value2.(bool)
562 case reflect.Slice:
563 // Special case for []byte
564 if type1.Elem().Kind() == reflect.Uint8 {
565 return bytes.Equal(value1.([]byte), value2.([]byte))
566 }
567 }
568
569 // For other types, return false
570 return false
571}
572
573// getListFromDB retrieves data from the database. When isKeyCanNotExist is true, it returns an empty slice if the key doesn't exist instead of an error.
574func (l *ListStructure) getListFromDB(key string, isKeyCanNotExist bool) (*list, int64, error) {

Callers 1

LRemMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected