Go

Go

By DeepSource

Use KeyMissing from go.etcd.io/etcd/client/v3/clientv3util instead GO-R1002

Anti-pattern

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

Signature of KeyMissing function:

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

Examples

Bad practice

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

Recommended

clientv3util.KeyMissing(key)