Go

Go

By DeepSource

Use KeyExists from go.etcd.io/etcd/client/v3/clientv3util instead GO-R1001

Anti-pattern

The call to the function could be abstracted by using a utility function called KeyExists from the package go.etcd.io/etcd/client/v3/clientv3util. It is recommended to use the KeyExists function instead.

Signature of KeyExists function:

func KeyExists(key string) clientv3.Cmp {
    return clientv3.Compare(clientv3.Version(key), ">", 0)
}

Examples

Bad practice

clientv3.Compare(clientv3.Version(key), ">", 0)

Recommended

clientv3util.KeyExists(key)