Go

Go

By DeepSource

Invalid `result` operator in `Compare` functionGO-E1003

Bug risk

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".

Examples

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