Go

Go

Made by DeepSource

Invalid result operator in Compare function GO-E1003

Bug risk
Critical

The Compare only allows the following operators as an argument to the result parameter:

  • "=" (equal operator)
  • "!=" (not equal operator)
  • ">" (greater than operator)
  • "<" (less than operator)

Any other operator would result in runtime panic with the message - "Unknown result op".

Bad practice

clientv3.Compare(clientv3.Value("b"), ">=", "a")

Recommended

// NOTE: It's not necessary that ">=" changes to ">". This is just an example.
clientv3.Compare(clientv3.Value("b"), ">", "a")

References